Microsoft Technology, .Net, BizTalk, Sharepoint & etc.

Liedong(Ken) Zheng, Senior SharePoint Developer at SIMPLOT

How To Connect mdf in app_data

Posted by ken zheng on September 17, 2008

Sometime people would like to put mdf in APP_Data so they can zip the database with the code.

the connection string will look like

That’s fine for SQL Express installed but if you are running SQL 2005, you may get error to connect the database.
After a while try, I found you can see the mdf from Server Explorer -> Data Connections. Try to connect the server and have a look the property. you will see the connection string like

Data Source=.\SQLEXPRESS;AttachDbFilename=”C:\VS2008 Projects\Ajax2008\Ajax2008\App_Data\Northwind.mdf”;Integrated Security=True;User Instance=True

So after I added the User Instance=True, it works.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>