Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my vb.net application needs a database, so i set sql database on my applicationData folder like this 'C:\Users\shani\AppData\Roaming' and i set connection string as 'Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\shani\AppData\Roaming\test.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True'.everything works correctly
But the problem is, if i install my application on any other computer connection string will get wrong.
how can my application retrieve sql database from ApplicationData folder without considering computer username
plz anyone answer.... am traped
Posted

1 solution

Try using DataDirectory--

SQL
"Data Source=AdityaSahVer\\SQLEXPRESS; Integrated Security=True;"AttachDbFilename=|DataDirectory|\DbFileName.mdf;Initial Catalog=Shipment"
 
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