Reputation: 8697
I'm trying to connect my database from my SQL Server to my asp.net project through the web.config
file. I found code like this which should be able to connect my SQL Server and ASP.net project together properly. 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
:
<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.
Upvotes: 0
Views: 213
Reputation: 35582
As the error suggests, the connection element should not go in system.web
section. it should go in configuration
section of your web.config
as
<configuration>
<connectionStrings>
---
Upvotes: 1