[英]Establishing connection of SQL Server 2008 with VS2012 project via web.config file
I'm trying to connect my database from my SQL Server to my asp.net project through the web.config
file. 我正在尝试通过
web.config
文件将数据库从SQL Server连接到asp.net项目。 I found code like this which should be able to connect my SQL Server and ASP.net project together properly. 我发现这样的代码应该可以将我的SQL Server和ASP.net项目正确地连接在一起。 However after adding this code, I got this error.
但是,添加此代码后,出现此错误。
This is my SQL Server connection string that is supposed to be place in web.config
: 这是我的SQL Server连接字符串,应该放在
web.config
:
<connectionStrings>
<add name="MyConnectionString"
connectionString="Data Source=sergio-desktop\sqlexpress;Initial
Catalog=MyDatabase;User ID=userName;Password=password"
providerName="System.Data.SqlClient" />
</connectionStrings>
And this is the error 这是错误
I'm also not very sure if the syntax of my connection string to establish connection between the two is correct. 我也不太确定我用来建立两者之间连接的连接字符串的语法是否正确。
As the error suggests, the connection element should not go in system.web
section. 如错误所示,连接元素不应放在
system.web
部分中。 it should go in configuration
section of your web.config
它应该进入您的
web.config
configuration
部分
as 如
<configuration>
<connectionStrings>
---
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.