在 C#中執行Sqlite數據庫事務有兩種方式:Sql代碼和C#代碼 1.Sql代碼: BEGIN… COMMIT /ROLLBACK 2.C#代碼: 復制代碼 using (SQLiteConnection conn = SqliteHelper.GetSQLiteConnection()) { DbTransaction trans = conn.BeginTransaction(); try { //Sql語句 trans.Commit();//提交事務 } catch (Exception e) { trans.Rollback();//回滾事務 } }