我正在使用 c# 应用程序并在服务器机器中将应用程序作为 Windows 服务运行。当我从客户端机器执行插入、更新删除操作时,它会引发数据库锁定错误,如下所示,
database is locked
at System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt)
at System.Data.SQLite.SQLiteDataReader.NextResult()
at System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCommand cmd, CommandBehavior behave)
at System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()
at System.Data.SQLite.SQLiteTransaction.Commit()
下面是我的代码
public int ExecuteNonQuerySQL(SQLiteCommand cmd)
{
int ireturn = 0;
if (conn.State != ConnectionState.Open)
Open(DataFile);
using (SQLiteTransaction dbtrans = conn.BeginTransaction(IsolationLevel.ReadCommitted))
{
using (cmd.Connection=conn)
{
cmd.CommandText =cmd.CommandText ;
cmd.Transaction = dbtrans;
ireturn = cmd.ExecuteNonQuery();
dbtrans.Commit();
cmd.Dispose();
}
}
}
请帮助我,我已经做了很多谷歌搜索,我必须找到一些解决方案来解决这个问题。问候