在我的项目中,我使用 sqlite 事务如下。
var trans = connection.BeginTransaction();
var sql = "delete from table1";
connection.ExecuteNonQuery(sql);
trans.Commit(); // Here, an exception occurred: "No transaction is active".
导致问题的原因是什么?
谁能帮我?
在我的项目中,我使用 sqlite 事务如下。
var trans = connection.BeginTransaction();
var sql = "delete from table1";
connection.ExecuteNonQuery(sql);
trans.Commit(); // Here, an exception occurred: "No transaction is active".
导致问题的原因是什么?
谁能帮我?
有同样的问题,我只是使用 BeginTransaction(IsolationLevel.ReadCommitted);
using (SQLiteConnection connection = new SQLiteConnection(DatabaseConnectionString))
{
connection.Open();
connection.BeginTransaction(IsolationLevel.ReadCommitted);
SQLiteCommand command = connection.CreateCommand();
command.CommandText = "delete from table1";
command.ExecuteNonQuery();
}
using (SQLiteConnection connection = new SQLiteConnection(DatabaseConnectionString))
{
connection.Open();
SQLiteCommand command = connection.CreateCommand();
command.CommandText = "delete from table1";
command.ExecuteNonQuery();
command.Dispose();
connection.Close();
}