VS 2013访问被拒绝连接到SQL Server 2012 Express .mdf文件 [英] VS 2013 Access Denied Connecting to SQL Server 2012 Express .mdf File

查看:149
本文介绍了VS 2013访问被拒绝连接到SQL Server 2012 Express .mdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手,这是我的第一篇文章,所以我不确定这是否是问我问题的正确地方.

我正在使用Visual Studio Community 2013(带有Update 5),并尝试访问正在创建的网站的.mdf文件时出现访问拒绝错误:

无法打开物理文件"C:\ BegASPNETCS \ Site \ App_Data \ PlanetWrox.mdf".操作系统错误5:"5(访问被拒绝.)".
尝试为文件C:\ BegASPNETCS \ Site \ App_Data \ PlanetWrox.mdf附加自动命名的数据库失败.存在具有相同名称的数据库,或者无法打开指定的文件,或者该数据库位于UNC共享上.

在VS Solution Explorer中,在App_Data文件夹下,双击.mdf文件并得到错误.或在服务器资源管理器中的数据连接"下,列出了.mdf文件,并带有一个红色的x.如果我右键单击该文件,请选择修改"->测试连接, 我也收到错误信息.

我通过使用Windows身份验证登录SQL Server Management Studio(从Windows开始菜单)来创建数据库.mdf文件(无错误),右键单击数据库"->添加数据库,然后从那里去.

这是我的家用电脑:
操作系统-Windows 7 Professional
SQL Server 2012 Express(SQLEXPRADV_x64_ENU.exe)-作为默认实例安装,并安装了除LocalDB之外的所有功能.

我的第一个问题是为什么我会收到访问被拒绝的错误,并且有办法解决吗?其次,安装LocalDB是否可以解决问题,如果可以,我应该已经安装了SQL Server 2012 Express怎么办?并有关系吗 它是作为默认实例安装的吗?

只是试图了解错误,并获得建议和一些最佳处理方法的指导.

谢谢!!
-Brian

Hi, I'm a newbie and this is my first post so I'm not sure if this is the correct place to ask my question.

I'm using Visual Studio Community 2013 (with Update 5) and getting an access denied error attempting to connect with an .mdf file for a web site I'm creating:

Unable to open the physical file "C:\BegASPNETCS\Site\App_Data\PlanetWrox.mdf". Operating system error 5: "5(Access is denied.)".
An attempt to attach an auto-named database for file C:\BegASPNETCS\Site\App_Data\PlanetWrox.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

In VS Solution Explorer, under the App_Data folder, I double-click the .mdf file and get the error. Or in Server Explorer, under Data Connections, the .mdf file is listed with a little red x. If I right-click the file there, chose Modify -> Test Connection, I get the error there as well.

I created the database .mdf file (without error) by logging into SQL Server Management Studio (from Windows start menu) using Windows Authentication, right-clicking Databases -> Add database and went from there.

This is my home PC:
OS - Windows 7 Professional
SQL Server 2012 Express (SQLEXPRADV_x64_ENU.exe) - Installed as a default instance, and installed all of the features except LocalDB.

My first question is why am I getting the access denied error, and is there a way around it? Secondly, would installing LocalDB resolve the problem, if so how would I do that being that I already have SQL Server 2012 Express installed? And will it matter that it was installed as a default instance?

Just trying to understand the error, and get a recommendation and some guidance on the best way to handle it.

Thank You!!!
-Brian

推荐答案

布莱恩

首先,请确保在复制mdf文件时没有打开连接.

First, please make sure you don't have a connection open to the mdf file when you copy it.

第二,打开服务器资源管理器"面板,右键单击数据连接".为了确保您选择了LocalDB,请参考以下屏幕截图:

Second, open the Server Explorer panel, right-click the Data Connections. To make sure you selected LocalDB, please refer to the following screenshot:

此外,请确保您也针对上述屏幕截图对webconfig文件进行了更改.

In addition, please make sure you make changes in webconfig file as well for above screenshot.

此致

奥斯卡


这篇关于VS 2013访问被拒绝连接到SQL Server 2012 Express .mdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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