vb.net 更新数据库失败,因为数据库是只读的
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20791512/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Failed to update database because the database is read only
提问by Pooh
This message appears every time I try to save the data to the DB.
每次我尝试将数据保存到数据库时都会出现此消息。
Failed to update database because the database is read only
Note: This error comes only when the application is installed to C drive.
注意:仅当应用程序安装到 C 盘时才会出现此错误。
Front End: VB.NET
前端:VB.NET
Back End:SQL Server
后端:SQL Server
Is there any way to overcome this issue? Or any way to restrict the user from installing the application on C drive?
有没有办法克服这个问题?或者有什么方法可以限制用户在C盘上安装应用程序?
采纳答案by Pantelis Natsiavas
I would check the file system privileges. I suppose you talk about an SQL server file database. You receive the message because the account trying to access your file database does not have the file system permissions to do so.
我会检查文件系统权限。我想您谈论的是 SQL 服务器文件数据库。您收到此消息是因为尝试访问您的文件数据库的帐户没有执行此操作的文件系统权限。
In order to confirm my suggestion, you allow everyoneto access the specific directory with full permissions.
Then, you have to check what is the account trying to do the actual access. Probably it's a system account (user ASPNET or NETWORK SERVICE). You have to give the respective permissions to the specific account.
Then, restart IIS.
为了确认我的建议,您允许所有人以完全权限访问特定目录。
然后,您必须检查尝试进行实际访问的帐户是什么。可能是系统帐户(用户 ASPNET 或 NETWORK SERVICE)。您必须为特定帐户授予相应的权限。
然后,重新启动 IIS。
If you want to do this for a distributed stand-alone application. Then these permissions would have to change on each machine where the program would be installed. In order to avoid putting users in such a fuss, the setup program should do it. I am not an expert on setup programs, but even the simplest ones would give you the option to do it, after asking the system adminstrator's approval. I suppose you could build a custom action during the setup program which would change the specific folder's permissions, perhaps by using xcacls.exe.
如果您想为分布式独立应用程序执行此操作。然后这些权限必须在安装程序的每台机器上更改。为了避免让用户如此大惊小怪,安装程序应该这样做。我不是安装程序的专家,但即使是最简单的程序,在征得系统管理员的同意后,也会为您提供选择。我想您可以在安装程序期间构建一个自定义操作,这将更改特定文件夹的权限,也许是通过使用xcacls.exe。
Hope I helped!
希望我有所帮助!

