Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection String to Connect to .MDF

I've created a new project in VS2008, and added a .MDF file to the project. This is the first time I've tried to use the MDF files and .SQLEXPRESS databases (I've always used extenal Oracle servers in the past).

I'm trying to document everything as I go, but I can't figure out what credentials are being used to connect to the .MDF file. Is there an easy way to find out?

like image 899
kdmurray Avatar asked May 30 '09 02:05

kdmurray


1 Answers

If you're using the *.mdf file in the App_Data folder of an ASP.NET app you can use this.

Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;Database=dbname; Trusted_Connection=Yes;

If it's not an ASP.NET application don't use the DataDirectory syntax and just use the full c:\... path.

like image 57
bendewey Avatar answered Oct 16 '22 21:10

bendewey