2

我正在运行一个 ISS 服务器,我有一个访问文件位于 C:\WCF\Access\ 我正在使用这个查询来插入一些东西:

@"INSERT INTO Arbejdsindsats (MedarYdelID, StartTid, SlutTid) VALUES ('" + medarYdelID + "', '" + startTid + "', '" + slutTid + "')";

完整的代码是:

public String GemArbejdsIndsats(String medarYdelID, String startTid, String slutTid)
        {
            try{
            con.Open();
            String command = @"INSERT INTO Arbejdsindsats (MedarYdelID, StartTid, SlutTid) VALUES ('" + medarYdelID + "', '" + startTid + "', '" + slutTid + "')";
            cmd.CommandText = command;
            cmd.ExecuteNonQuery();
            con.Close();


                return "success: medarydelid: " + medarYdelID + " startTid: " + startTid + " slutTid: " + slutTid;
            } catch(Exception e)
                {
                    String k = e.Message;
                    return k;
                }
        }

问题是这个错误:

操作必须使用可更新的查询

当我在自己的机器上进行本地测试时,它工作正常。只是不在IIS中。

奇怪的是有一个 laccdb 文件。它不会消失。也许数据库被锁定,这就是为什么我不能更新它?

权限应该不是问题:

img http://img.ctrlv.in/50c0dbf8670d8.jpg

4

3 回答 3

5

The user account must be able to write to the files and to the folder in which they are located; it should be able to create and delete files in the folder. The presence of the laccdb file does not necessarily mean that access has locked the database. Its presence could be the result of any of several circumstances, one of which could be that the user account doesn't have permission to delete files from the folder.

于 2012-12-06T19:12:40.370 回答
1

这个问题的解决方案非常简单。只需以管理员身份运行该应用程序。我试了 3 次,效果很好

于 2016-12-04T09:55:43.590 回答
0

此外,请确保该文件不是只读的。

于 2018-03-08T22:42:15.407 回答