internal static bool ResetConnection(SQLiteConnectionHandle hdl, IntPtr db, bool canThrow) { SQLiteErrorCode sQLiteErrorCode; if (hdl == null || db == IntPtr.Zero) { return(false); } bool flag = false; try { } finally { lock (hdl) { if (canThrow && hdl.IsInvalid) { throw new InvalidOperationException("The connection handle is invalid."); } if (canThrow && hdl.IsClosed) { throw new InvalidOperationException("The connection handle is closed."); } if (!hdl.IsInvalid && !hdl.IsClosed) { IntPtr zero = IntPtr.Zero; do { zero = UnsafeNativeMethods.sqlite3_next_stmt(db, zero); if (zero == IntPtr.Zero) { continue; } sQLiteErrorCode = UnsafeNativeMethods.sqlite3_reset_interop(zero); }while (zero != IntPtr.Zero); if (!SQLiteBase.IsAutocommit(hdl, db)) { sQLiteErrorCode = UnsafeNativeMethods.sqlite3_exec(db, SQLiteConvert.ToUTF8("ROLLBACK"), IntPtr.Zero, IntPtr.Zero, ref zero); if (sQLiteErrorCode == SQLiteErrorCode.Ok) { flag = true; } else if (canThrow) { throw new SQLiteException(sQLiteErrorCode, SQLiteBase.GetLastError(hdl, db)); } } else { flag = true; } } } } GC.KeepAlive(hdl); return(flag); }
internal static void CloseConnectionV2(SQLiteConnectionHandle hdl, IntPtr db) { if (hdl == null || db == IntPtr.Zero) { return; } try { } finally { lock (hdl) { SQLiteErrorCode sQLiteErrorCode = UnsafeNativeMethods.sqlite3_close_interop(db); if (sQLiteErrorCode != SQLiteErrorCode.Ok) { throw new SQLiteException(sQLiteErrorCode, SQLiteBase.GetLastError(hdl, db)); } } } }
public void Reset(bool clearBindings, bool ignoreErrors) { this.CheckDisposed(); if (clearBindings && this._parameterCollection != null) { this._parameterCollection.Unbind(); } this.ClearDataReader(); if (this._statementList == null) { return; } SQLiteBase sQLiteBase = this._cnn._sql; foreach (SQLiteStatement sQLiteStatement in this._statementList) { if (sQLiteStatement == null) { continue; } SQLiteStatementHandle _sqliteStmt = sQLiteStatement._sqlite_stmt; if (_sqliteStmt == null) { continue; } SQLiteErrorCode sQLiteErrorCode = sQLiteBase.Reset(sQLiteStatement); if (sQLiteErrorCode == SQLiteErrorCode.Ok && clearBindings && SQLite3.SQLiteVersionNumber >= 3003007) { sQLiteErrorCode = UnsafeNativeMethods.sqlite3_clear_bindings(_sqliteStmt); } if (ignoreErrors || sQLiteErrorCode == SQLiteErrorCode.Ok) { continue; } throw new SQLiteException(sQLiteErrorCode, sQLiteBase.GetLastError()); } }