开发者

VS2010 and local databases

Is it possible to connect to a local database (in the app_data folder) using the Data -> Transact S开发者_高级运维QL Editor in Visual Studio 2010?

When I launch the Transact SQL Editor from VS2010 I get the "Microsoft SQL Server 2008 RC" connect to server dialog. The options I have for Server type are "Database Engine" and "SQL Server Compact"


I was able to connect to a local database by using the AttachDbFilename connection string option (as it is done e.g. in Web.config).

In "Connect to Database Engine" dialog, click "Options >>", go to "Additional Connection Parameters" tab and enter something like the following:

Data Source=.\SQLEXPRESS;AttachDbFilename=<your_path_to_app>\App_Data\YourDatabase.mdf;Integrated Security=True;User Instance=true;Initial Catalog=YourDatabase

The only problem with this method is that the options are not saved in the dialog, and the connection string has to be entered with every connection.


What you can do is:

  • CTRL + ALT + S (show up Server Explorer)

  • Add Connection.

  • Click "Change" right from Data Source and select Microsoft SQL Server Data File

Now youshould be able to select any SQL Server file now for your connection.

  • Click on Data -> Transact SQL Editor > New Connection. SQL Server Connection Dialog will appear.
  • In the list, choose SQL Server Compact and browse for SDF-file.
  • Click Connect and you should be connected now.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜