1

在我的项目中,我使用 sqlite 事务如下。

var trans = connection.BeginTransaction();

var sql = "delete from table1";
connection.ExecuteNonQuery(sql);

trans.Commit(); // Here, an exception occurred: "No transaction is active".

导致问题的原因是什么?
谁能帮我?

4

2 回答 2

1

有同样的问题,我只是使用 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();
}
于 2014-04-07T14:57:22.263 回答
0
using (SQLiteConnection connection = new SQLiteConnection(DatabaseConnectionString))
{
    connection.Open();
    SQLiteCommand command = connection.CreateCommand();
    command.CommandText = "delete from table1";
    command.ExecuteNonQuery();
    command.Dispose();
    connection.Close();
}
于 2012-10-22T13:16:29.613 回答