I created an windows form application in c# during development i used following connection string and it works fine
Code
add name="myconnection" connectionString="Data Source=ABC-PC\SQLEXPRESS;Initial Catalog=mydatabase;Integrated Security=True"/> connectionStrings>Code
add name="myconnection" connectionString="Data Source=.\SQLEXPRESS; Integrated Security=True; User Instance=True;AttachDbFilename=|DataDirectory|\mydatabase.mdf; Initial Catalog=mydatabase; "/> connectionStrings>Unable to open the physical file "D:\Other Projects\Employee\Employee\bin\Debug\mydatabase.mdf". Operating system error 2: "2(The system cannot find the file specified.)". Cannot attach the file 'D:\Other Projects\Employee\Employee\bin\Debug\mydatabase.mdf' as database 'mydatabase'.
and calling connection string as
Code
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["myconnection"].ConnectionString);
Rajeesh MenothRank #118 · 18.4K reputationPosted Jun 30, 2015, 3:38 AM EDT
waqas shah56 reputationPosted Jun 30, 2015, 3:52 AM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Jun 30, 2015, 3:57 AM EDT
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Jun 30, 2015, 4:25 AM EDT
waqas shah56 reputationPosted Jun 30, 2015, 9:35 PM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Jun 30, 2015, 9:38 PM EDT
waqas shah56 reputationPosted Jun 30, 2015, 10:08 PM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Jun 30, 2015, 10:10 PM EDT