Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends ,

I am trying make a setup file for my project.

My connection string ;

con.ConnectionString = "Server=.\\SQLExpress;AttachDbFilename=|DataDirectory|mynewproject.mdf;Trusted_Connection=True"


After create setup file , i have a exe file. I'm install this file everything is okay. I see my database in my programs ( which one is installed ) directory. When i open my program , its giving an error : database not found by my program.

I guess , i must be change my connection string. But i don't know what should be my connection string.
Posted

Use full path for AttachDbFileName=e:\data\mynewproject.mdf


See more info
http://msdn.microsoft.com/en-us/library/ms247257(v=vs.100).ASPX
 
Share this answer
 
Comments
kozmikadam 14-Mar-14 7:23am    
But for every computer , installation file directory can be change.
You can dynamically create your DB Connection string using SqlConnectionStringBuilder class.
Look at this link:
http://msdn.microsoft.com/pl-pl/library/system.data.sqlclient.sqlconnectionstringbuilder%28v=vs.110%29.aspx[^]
 
Share this answer
 

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