Reputation: 77
I am using MDF file for database in windows form for that purpose I have to write the full path in the connection string i.e.
Data Source=`(LocalDB)\v11.0;AttachDbFilename="C:\Users\adeel\Documents\Visual Studio 2013\Projects\WPFwithSampleDB\WPFwithSampleDB\Database1.mdf";Integrated Security=True
I want to change this path of AttachDbFilename
as user install my program in their machine, I changed this path to
(LocalDB)\v11.0;AttachDbFilename="Database1.mdf";Integrated Security=True
But it does not work
Upvotes: 1
Views: 797
Reputation: 39956
Try |DataDirectory|
. It eliminates the need to hard-code the full path and also makes it easy to share a project and also to deploy an application. Like this:
AttachDbFilename=|DataDirectory|\Database1.mdf;
Have a look at this: Working with local databases
.
Upvotes: 2