无法打开物理文件失败.存在同名数据库,或无法打开指定文件,或位于 UNC 共享 [英] Unable to open the physical file failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share

查看:27
本文介绍了无法打开物理文件失败.存在同名数据库,或无法打开指定文件,或位于 UNC 共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经根据我的作业目的开发了网站,然后我的老师问我他没有 SQL Server 来单独运行我的数据库文件,所以我必须制作内置数据库.然后我将 .mdf 文件添加到 App_data 文件夹并使用此连接字符串:

I have developed and website as for my assignment purpose and then my teacher asked me that he doesn't have SQL Server to run separately my database file so I must have to make built in database. I then added the .mdf file to the App_data folder and used this connection string:

<add name="dbCanberraConnectionString1"
     connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|latestcanberra.mdf;"
     providerName="System.Data.SqlClient" />

web.config 中.但是当我尝试运行我的网站时,它显示了一个错误

in web.config. But when I tried to run my website it shows an error

无法打开物理文件D:\Complete Assignment\Alkandi Final Work\App_Data\latestcanberra.mdf".操作系统错误 5:5(访问被拒绝.)

Unable to open the physical file "D:\Complete Assignment\Alkandi Final Work\App_Data\latestcanberra.mdf". Operating system error 5: "5(Access is denied.)

尝试为文件 D:\Complete Assignment\Alkandi Final Work\App_Data\latestcanberra.mdf 附加自动命名的数据库失败.存在同名数据库,或无法打开指定文件,或位于 UNC 共享.

An attempt to attach an auto-named database for file D:\Complete Assignment\Alkandi Final Work\App_Data\latestcanberra.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

我从过去 3 小时开始就完全被这个错误所困扰,即使我通过从不同的博客等搜索解决方案尝试了不同的方法

I am totally stuck with this error from last 3 hours even I tried different methods by searching solutions from different blogs etc

知道如何在更短的时间内解决这个问题吗?

Any idea how to solve this out within less time ?

推荐答案

将完全控制权交给经过身份验证的用户".如果安全设置中没有此用户,则添加它.

Give full control to your "Authenticated Users". If there is no this user in the security settings then add it.

如果您想知道如何执行此操作 --- 我使用的是 Windows 7,步骤如下:

In case you are wondering how to do this --- I am on Windows 7 and the steps go like this:

右键单击 MDF 文件并单击属性.选择安全"选项卡并选择经过身份验证的用户"或单击编辑"按钮,然后单击添加"按钮,然后写入经过身份验证的用户",然后单击检查名称"按钮.然后确定"按钮.单击编辑"并选择完全控制"的允许"复选框.一路走好.

Right-click on the MDF file and click properties. Select the "Security" tab and select your "Authenticated Users" or click 'Edit' Button then 'Add' button then write 'Autheticated Users' and then 'Check Names' button. Then 'OK' button. Click "Edit" and select the "Allow" check-box for "Full Control". OK all the way out.

这篇关于无法打开物理文件失败.存在同名数据库,或无法打开指定文件,或位于 UNC 共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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