运行SQLite命令时出现错误消息 - 数据库已锁定。 [英] Error mesage when I run a SQLite command - Database is locked.

查看:125
本文介绍了运行SQLite命令时出现错误消息 - 数据库已锁定。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一些代码,但是当我运行它时会显示错误。

I have some code, but it shows me an error when I run it.

Werror msg:数据库文件被锁定数据库被锁定

Werror msg: The database file is locked database is locked

我的代码:

try
{
    string query = "UPDATE Table1 SET column1 = @col1 WHERE columnID = @colID AND column2 = @col2;";
    using (SQLiteConnection con = new SQLiteConnection(conString))
    {
        con.open();
        using (SQLiteCommand cmd = new SQLiteCommand(query, con))
        {
            foreach (Data d in list)
            {
                cmd.Parameters.AddWithValue("@col1", d._date);
                cmd.Parameters.AddWithValue("@col2", String.Empty);
                cmd.Parameters.AddWithValue("@colID", d._clientID);
                cmd.ExecuteNonQuery();
            }
        }
    }
}
catch(Exception ex)
{
    MessageBox.Show("Error : " + ex.Message);
}

你能看到问题吗?什么错了?

Can you see the problem? Whats wrong?

推荐答案

显示的代码没有问题。任何问题都是外部的另一个进程使数据库独占打开或在项目的其他位置打开数据库而不关闭连接。所以重复一遍,显示的代码是
罚款。
There is no problem with the code shown. Any issues are external e.g. another process has the database open exclusively or someplace else in your project you have opened the database and not closed the connection. So to repeat myself, the code shown is fine.


这篇关于运行SQLite命令时出现错误消息 - 数据库已锁定。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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