I’ve got a strange thing happening with my app.config file. My ConnectionStrings section contains this:
<connectionStrings> <add name='Connection' connectionString='Data Source=TheServer; Initial Catalog=TheDatabase;IntegratedSecurity=SSPI' providerName='System.Data.SqlClient'/> </connectionStrings>
However, when I query the section via ConfigurationManager.ConnectionStrings[0], I get back this connection string:
Data Source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true
Where is it getting this value from?
It is read from machine.config, you can either make sure to clear all connection strings before adding your own:
Or just never reference your connection strings by indexes, use names you give them: