DRAG DROP
There is MS Visual Studio 2010 and MS .NET Framework 4 application PassGuideApp.
PassGuideApp connects to a MS SQL Server Express 2008 database PassGuideDB.
The primary database file of PassGuideDB is PassGuideDB.mdf.
PassGuideDB.mdf is stored in the App_data folder.
You want to set up the connection between PassGuideApp and PassGuideDB.
What do you need to do?
You want to set up the connection between PassGuideApp and PassGuideDB.
DRAG DROP
There is MS Visual Studio 2010 and MS .NET Framework 4 application PassGuideApp.
PassGuideApp connects to a MS SQL Server Express 2008 database PassGuideDB.
The primary database file of PassGuideDB is PassGuideDB.mdf.
PassGuideDB.mdf is stored in the App_data folder.
You want to set up the connection between PassGuideApp and PassGuideDB.
What do you need to do?
Here’s is the first result that comes up when you google ‘mdf connection string’:
http://forums.asp.net/t/1246174.aspx?ConnectionString+to+access+mdf+file+in+App_Data+folder
And the connection string specified in that link is similar to the one specified by the answer here, so I’ll just go ahead and assume the answer is correct.
I did a bit of extra research in the following link as well:
http://msdn.microsoft.com/en-us/library/jj653752%28v=vs.110%29.aspx
And didn’t find any issues with the answer, so it looks good.
Also good to know, that the |DataDirectory| is only for Web application to select the App_Data directory of the web application. Thas why web.config is picked in the answer.
However, you can prepare you desktop application to be able to consume a connection sting with a |DataDirectory| part in it:
http://stackoverflow.com/questions/3500829/sql-express-connection-string-relative-to-application-location