I've import my SQL 2005 database to my project and i am trying to connect to the database using the web.config
But I've this error when I add the connectionString to the web.config.
<add name="strConn" connectionString="Data Source=.\sqlexpress;Initial Catalog=intranet_db;Integrated Security=True"
providerName="System.Data.SqlClient"/>
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid. Detailed Error Information:
Request Tracing Directory
C:\Users\user\Documents\IISExpress\TraceLogFiles\
Am I doing it wrong? What should I add in the web.config?
Thanks.
it should be something like this
<connectionStrings>
<add name="connectionString" connectionString="Provider=SQLOLEDB.1;Data Source=dbhostname;Persist Security Info=True;Password='password';User ID='username';Initial Catalog=dbname" />
</connectionStrings>
Please make sure you put the "add" tag in the correct place. I'm able to reproduce your error when I place it i wrong section. Your web.config file should look like this:
<configuration>
<connectionStrings>
<add name="strConn" connectionString="Data Source=.\sqlexpress;Initial Catalog=intranet_db;Integrated Security=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>
have a look at http://www.connectionstrings.com/ it has examples of what they should be.
looking at you connection string make sure the instance name ./SqlExpress is correct.
A quick test would be to load sql manager and connect with the ./SqlExpress
Standard Security
Server=myServerAddress;Database=myDataBase;User Id=myUsername; Password=myPassword;
Trusted Connection Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
to give you a better answer would require knowing how you want to connect to the database.
User contributions licensed under CC BY-SA 3.0