Question

I'm using System.Data.Linq.DataContext file for accessing a mdf Database

I want to use the Database from the project directory and not the one created by the debugger in the Debug directory.

The problem is when I edit the Connection String and choose the path for AttachDBFilename, VS2008 automaticly substitutes my project directory with "|DataDirectory|"

How do I get arround this one?

Was it helpful?

Solution

Edit your application "app.config" file
Go to the connectionStrings and change the connectionString to the path of your DB.

At the DataContext file properties, set the "Application Settings" = True
Then choose the Connection by it's name and that it.

OTHER TIPS

already you can write like this: SampledbDataContext sdc = new SampledbDataContext(Server.MapPath("~/Sampledb.mdf")); or in design.cs file public SampledbDataContext() : base(global::"[write cnn string Here !]", mappingSource) { OnCreated(); }

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top