public int ExecuteNonQuery(object[] source) { if (Connection.Trace) { Debug.WriteLine("Executing: " + CommandText); } var r = SQLite3.Result.OK; if (!Initialized) { Statement = Prepare(); Initialized = true; } //bind the values. if (source != null) { for (int i = 0; i < source.Length; i++) { SQLiteCommand.BindParameter(Statement, i + 1, source[i], Connection.StoreDateTimeAsTicks); } } r = SQLite3.Step(Statement); if (r == SQLite3.Result.Done) { int rowsAffected = SQLite3.Changes(Connection.Handle); SQLite3.Reset(Statement); return(rowsAffected); } else if (r == SQLite3.Result.Error) { string msg = SQLite3.GetErrmsg(Connection.Handle); SQLite3.Reset(Statement); throw SQLiteException.New(r, msg); } else if (r == SQLite3.Result.Constraint && SQLite3.ExtendedErrCode(Connection.Handle) == SQLite3.ExtendedResult.ConstraintNotNull) { SQLite3.Reset(Statement); throw NotNullConstraintViolationException.New(r, SQLite3.GetErrmsg(Connection.Handle)); } else { SQLite3.Reset(Statement); throw SQLiteException.New(r, r.ToString()); } }
public int ExecuteNonQuery(object[] source) { if (Connection.Trace) { Connection.InvokeTrace("Executing: " + CommandText); } SQLite3.Result result = SQLite3.Result.OK; if (!Initialized) { Statement = Prepare(); Initialized = true; } if (source != null) { for (int i = 0; i < source.Length; i++) { SQLiteCommand.BindParameter(Statement, i + 1, source[i], Connection.StoreDateTimeAsTicks); } } result = SQLite3.Step(Statement); switch (result) { case SQLite3.Result.Done: { int result2 = SQLite3.Changes(Connection.Handle); SQLite3.Reset(Statement); return(result2); } case SQLite3.Result.Error: { string errmsg = SQLite3.GetErrmsg(Connection.Handle); SQLite3.Reset(Statement); throw SQLiteException.New(result, errmsg); } case SQLite3.Result.Constraint: if (SQLite3.ExtendedErrCode(Connection.Handle) == SQLite3.ExtendedResult.ConstraintNotNull) { SQLite3.Reset(Statement); throw NotNullConstraintViolationException.New(result, SQLite3.GetErrmsg(Connection.Handle)); } break; } SQLite3.Reset(Statement); throw SQLiteException.New(result, result.ToString()); }