I created an windows form application in c# during development i used following connection string and it works fine
<add name="myconnection" connectionString="Data Source=ABC-PC\SQLEXPRESS;Initial Catalog=mydatabase;Integrated Security=True"/> connectionStrings>but now i need to deploy application on client machine and i have to add data directory option in my connection string and i did this as <add name="myconnection" connectionString="Data Source=.\SQLEXPRESS; Integrated Security=True; User Instance=True;AttachDbFilename=|DataDirectory|\mydatabase.mdf; Initial Catalog=mydatabase; "/> connectionStrings>when i changed string then it threw and errorUnable 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
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["myconnection"].ConnectionString); I used SQL server 2008.
Rajeesh MenothPosted Jul 1, 2015, 2:10 AM
waqas shahPosted Jul 1, 2015, 2:08 AM
Rajeesh MenothPosted Jul 1, 2015, 1:38 AM
waqas shahPosted Jul 1, 2015, 1:35 AM
Upendra Pratap ShahiPosted Jun 30, 2015, 8:25 AM
Rajeesh MenothPosted Jun 30, 2015, 7:57 AM
waqas shahPosted Jun 30, 2015, 7:52 AM
Rajeesh MenothPosted Jun 30, 2015, 7:38 AM