Kamis, 21 April 2011

MDF in Microsoft Visual Studio 2010

MDF is a file which is used by SQL Server to save its data. It can be found in your SQL Server installation folder, whether it's express or not. But be careful, the MDF files should always with the LDF files in order for it to work.

Connecting to an MDF file to Microsoft Visual Studio 2010, can be done through Server Explorer. Look at the exhibit below.


Then, you have to choose Microsoft SQL Server Database File in Change Data Source dialog.

If you're facing the exhibit below, just point your mouse to Change button and change the data source.

At last, browse for the MDF file you want to connect.

Voila! The MDF file can then be read for your application.

ps: To be able to edit the content of the MDF files, you should put the files in unrestricted folder (a folder which has the priviledge to read, write, or modify).