Click here to Skip to main content
15,844,477 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.

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

See more info
Share this answer
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:[^]
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