Force Full path in the Linq DataContext connection string
I am using System.Data.Linq.DataContext file to access mdf database
I want to use a database from the project directory, not the one created by the debugger in the Debug directory.
The problem is when I edit my connection string and select the path for AttachDBFilename, VS2008 automatically replaces my project directory "| DataDirectory |"
How to get arround this one?
Edit your app.config file
Go to connectionStrings and change connectionString to your database path.
In the properties of the DataContext file set "Application Settings" = True
Then select Connection by name and its.
already you can write like this: SampledbDataContext sdc = new SampledbDataContext (Server.MapPath ("~ / Sampledb.mdf")); or in the file design.cs public SampledbDataContext (): base (global :: "[write cnn string Here!]", mappingSource) {OnCreated (); }