无法更新数据库.MDF是只读 [英] Unable to update database .MDF is Read Only

查看:174
本文介绍了无法更新数据库.MDF是只读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个本地数据库,我有一个应用程序。当我在另一台机器上安装它时,出现错误

I have a local DB that I have in an application. When I install it on another machine I get the error


无法更新数据库.. .mdf是只读的。

Unable to update database.. .mdf is read only.

我可以通过编辑我们对 .mdf 和日志文件的权限来解决。我做了一些研究,并注意到,我可能要将数据库安装到共享文件夹。但是,我不知道该怎么做,我遇到的答案没有太大意义。

I was able to get around it by editing my permissions on the .mdf and log file themselves. I did some research and noticed that I may want to install the database to a shared folder. However, I am not sure how to do that and the answers I did come across did not make a whole lot of sense to be.

 //My connection string
 SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|AssetDatabase.mdf;Integrated Security=True");

任何指导都将非常感谢。我正在学习。

Any guidance would be greatly appreciated. I am learning.

推荐答案

MDF文件将是readonly,因为只读文件属性标志设置,以取消设置,或者另一个程序将MDF文件锁定为只读。您是否正在运行使用该文件的SQL Server版本?

The MDF file would be readonly either because the readonly file attribute flag is set, in which case you have to unset it, or another program has the MDF file locked as readonly. Are you running a version of SQL server that is using that file?

我从来没有直接看到过MDF文件的连接,通常是通过服务器完成的,服务器将管理MDF文件的所有IO。

I've never seen a connection to the MDF file directly, usually it's done via the server, and the server will manage all the IO for the MDF file.

Eg

Database=<dbname>;Server=<servername>;MultipleActiveResultSets=True;Connection Timeout=10;User Id=<username>;Password=<password>;

其他链接:

1) a href =http://stackoverflow.com/questions/5713416/failed-to-update-mdf-database-because-the-database-is-read-only-windows-applic>无法更新.mdf数据库,因为数据库是只读的(Windows应用程序)

1) Failed to update .mdf database because the database is read-only (Windows application)

2)无法更新数据库,因为它是只读的

3)无法更新资料库「*。mdf」因为只读EntityFramework

4) http://www.codeproject.com/Questions/183758/Failed-to-update-mdf-database-because-the-database

这篇关于无法更新数据库.MDF是只读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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