Posted on: 1/21/2015 10:25:19 PM | Views : 643

Hi all,
In my code if I use hard coded string in sql connection it works but if I try to read it from web.onfig it gives me an error, so what works is
con = new SqlConnection ("Data Source=ENMPLS5142W\\SQLEXPRESS;Initial Catalog=JobTracker;User ID=xxxxxx;Password=xxxxx"); con.Open(); what gives me error is
con = new SqlConnection(ConfigurationManager.ConnectionStrings["JobTrackerDB"].ConnectionString); web.xml config is as belows
<connectionStrings> <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-WebForms-20150119031845.mdf;Initial Catalog=aspnet-WebForms-20150119031845;Integrated Security=True" providerName="System.Data.SqlClient" /> <add name="JobTrackerEntities" conne ...

Go to the complete details ...