Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in my web.config file i have defined only one connection string but system.configuration.configurationmanager.connectionstrings is showing me 2.

system.configuration.configurationmanager.connectionstrings[0].connectionstrings="datasource=.\\sqlexpress"


which i didn't define anywhere. FYI when i created the edmx model. i used this string but later i removed it.but still it appears.
Posted

1 solution

Add name attribute for your connectionString in web.config then :
C#
ConfigurationManager.ConnectionStrings["Con_Name"].ConnectionStrings

Let me know if it works!

I think you will find your answer of 'Why it happens?' here:
10 Things ASP.NET Developers Should Know About Web.config Inheritance and Overrides[^]
 
Share this answer
 
v2
Comments
scorpzonex 20-Apr-14 16:04pm    
it works thank you. but my question was why? not how. why i'm getting two connection strings.
Meysam Toluie 22-Apr-14 0:56am    
See the update.
I hope you get what you want!
scorpzonex 22-Apr-14 19:54pm    
thank you. now i got the whole idea.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900