简体   繁体   English

我无法在Visual Studio 2008中打开mdf文件-像txt文件一样打开文件,而在Managament Studio中则无法打开

[英]I can't open mdf file in Visual Studio 2008 - file open like txt file and not in managament studio

I have Visual Studio 2008 and ASP.NET MVC2 project. 我有Visual Studio 2008和ASP.NET MVC2项目。 To App_data folder I added ContactManager.mdf file (Add existing item). 我向App_data文件夹添加了ContactManager.mdf文件(添加现有项)。 Now I try this file to add tables to this database. 现在,我尝试使用该文件向该数据库添加表。 But when I double-click this file it open like txt file: cŔ>xň›G0- ... And it should open in editor which looks like Management Studio when I can create tables in Visual Studio without open MS SQL Management Studio. 但是,当我双击该文件时,它像txt文件一样打开:cŔ>xň› G0- ...并且当我可以在Visual Studio中创建表而无需打开MS SQL Management Studio时,它应该在类似于Management Studio的编辑器中打开。 I thik that I must install any application but I don't know which. 我想我必须安装任何应用程序,但我不知道该安装哪个。 I have full version Visual Studio 2008. 我有完整版的Visual Studio 2008。


When I get right-click on App_data then Add new item and select SQL Server database and click Add messagebox with error: Object reference not set to an instance of an object is showed. 当我右键单击App_data时,然后添加新项并选择SQL Server数据库,然后单击添加错误消息框:显示未设置为对象实例的对象引用。

I always use "Microsoft SQL Server Management Studio Express" for managing MS SQL database services instances and database files. 我始终使用“ Microsoft SQL Server Management Studio Express”来管理MS SQL数据库服务实例和数据库文件。 With it you are able to log on to your sql instance and mount (or restore) the mdf file to a database. 使用它,您可以登录到sql实例并将mdf文件安装(或还原)到数据库。

The application is from Microsoft and is free! 该应用程序来自Microsoft,并且是免费的! http://www.microsoft.com/download/en/details.aspx?id=8961 http://www.microsoft.com/download/zh-CN/details.aspx?id=8961

Mdf file is not readable as is. Mdf文件无法原样读取。 You have to "mount" the MDF file in a running instance of Sql Server, either under sql service, or user instance (easiest in VS). 您必须在SQL Server或用户实例(在VS中最简单)下的Sql Server运行实例中“挂载” MDF文件。

After that, you can open the DB using the connection manager window of VS. 之后,您可以使用VS的连接管理器窗口打开数据库。 VS will automatically find the db in the app_data folder and provide a ready to use connection to it. VS会自动在app_data文件夹中找到该数据库,并提供一个可供使用的连接。

try to open it from visual studio environment from any new application go to view->other windows->database explorer which will appear in the left side. 尝试从Visual Studio环境中通过任何新应用程序将其打开,然后转到显示在左侧的“视图”->“其他窗口”->“数据库资源管理器”。 then click on new connection , the menue that will be appeared containing brows then select your database that you want to add tables and whatever...... 然后单击“新建连接”,将出现包含眉毛的菜单,然后选择要添加表的数据库以及其他任何内容……

In the server explorer window (top-left of vs 2008) can you see the database? 在服务器资源管理器窗口(vs 2008的左上方)中,您可以看到数据库吗? If yes, right click on the table and add new. 如果是,请右键单击表并添加新的。 I suspect there is a problem with your vs installation 我怀疑您的vs安装有问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM