无法访问通过Visual Studio创建的数据库? [英] Can't gain access to my database created though Visual Studio?

查看:362
本文介绍了无法访问通过Visual Studio创建的数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个数据库 emailDatabase ,它存储在

  C:\Program Files \Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA 

在Visual Studio中,我使用服务器资源管理器,单击添加新连接按钮。



将显示添加连接对话框。 >

在服务器名称下,我使用下拉框并选择 DEV-5\SQLEXPRESS 。我使用Windows身份验证。



在底部的连接到部分,下拉列表显示: ,msdb tempdb ,并且不显示我的 emailDatabase



因此,我选择附加数据库文件,然后单击浏览并按照

  local C:\Program Files \Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA 

并选择我的电子邮件数据库。



发生以下错误:


emailDatabase

您没有权限打开此文件。

联系文件所有者或管理员以获取权限。


我认为我的问题是我保存了我的数据库错误,我需要做一个备份或类似的东西。如果是这样的情况,请告诉我如何做备份等等。



当我创建数据库时,右键单击SQL Server Management Studio中的数据库,然后说新数据库,然后我添加了列带有查询。然后文件保存所有。



如何获得我的数据库文件的所有权限的副本,我需要在visual Studio中使用它

解决方案

在服务器上(使用SQL Server Management Studio)创建数据库时,您不必



而是:执行添加连接在Visual Studio中,然后指定服务器实例( DEV-5 \SQLEXPRESS )和数据库名称( emailDatabase )在您的连接对话框中。



有了这个,你连接和使用一个SQL Server数据库的方式,在SQL Server实例本身。这比使用自由浮动 .mdf 文件并将它们附加到您的解决方案更简单,更少麻烦了。



>



这里 - 在您的服务器名称下拉菜单中填入 DEV-5\SQLEXPRESS ,然后使用选择或输入数据库名称选项并输入您的数据库名称(或从下拉菜单中选择) - 它应该在那里!



附加数据库文件选项 - 这是自由浮动的 .mdf 功能这是相当笨拙,很难使用和容易出错 - 再次:我建议使用...


I have created a database emailDatabase, its stored in

C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA

In Visual Studio, I use the Server Explorer, click the add new connection button.

The add connection dialog box appears.

Under server name I use the dropdown box and select DEV-5\SQLEXPRESS. I use Windows authentication.

In the Connect to section at the bottom, the dropdown displays: Master, Model, msdb and tempdb and does not display my emailDatabase.

So I select Attach Database File and click browse and follow

local C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA

and select my email database.

The following error occurs :

emailDatabase
You don not have permission to open this file.
Contact file owner or an administrator to obtain permission.

I think my problem is i saved my database wrong, I need to make a back up or something like that. if that's the case please tel me how to make a backup and so on. I really need to move forward from this problem.

When I created my database I right-clicked on databases in SQL Server Management Studio and said new database, then I added columns with a query. then file save all.

How can I get a copy of my database file with all the permissions I need to use it in visual Studio??

解决方案

When you create a database on the server (using SQL Server Management Studio), you don't have to (and should not!) fiddle around with the database file(s) anymore - let the server handle that for you.

Instead: do a Add Connection in Visual Studio and then specify the server instance (DEV-5\SQLEXPRESS) and the database name (emailDatabase) in your connection dialog.

With this, you're connecting and using a SQL Server database the way it's intended to be used - on the SQL Server instance itself. This is much easier, and much less hassle, than having to struggle with "free-floating" .mdf files and attaching them to your solutions and stuff like that....

So here - fill in DEV-5\SQLEXPRESS into your "Server name" dropdown, and then use the "Select or enter database name" option and enter your database name (or pick it from the dropdown) - it should be there!

DO NOT use the "Attach a database file" option - this is the free-floating .mdf "feature" which is rather clumsy and hard to use and error-prone - again: I recommend not using that...

这篇关于无法访问通过Visual Studio创建的数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆