public int ExecuteNonQuery() { _conn.TraceListener.WriteLine("Executing: {0}", this); var stmt = Prepare(); var r = _sqlitePlatform.SQLiteApi.Step(stmt); Finalize(stmt); if (r == Result.Done) { var rowsAffected = _sqlitePlatform.SQLiteApi.Changes(_conn.Handle); return(rowsAffected); } if (r == Result.Error) { var msg = _sqlitePlatform.SQLiteApi.Errmsg16(_conn.Handle); throw SQLiteException.New(r, msg); } if (r == Result.Constraint) { if (_sqlitePlatform.SQLiteApi.ExtendedErrCode(_conn.Handle) == ExtendedResult.ConstraintNotNull) { throw NotNullConstraintViolationException.New(r, _sqlitePlatform.SQLiteApi.Errmsg16(_conn.Handle)); } } throw SQLiteException.New(r, r.ToString()); }
public int ExecuteNonQuery(object[] source) { Connection.TraceListener.WriteLine("Executing: {0}", CommandText); if (!Initialized) { Statement = Prepare(); Initialized = true; } var sqlitePlatform = Connection.Platform; //bind the values. if (source != null) { for (var i = 0; i < source.Length; i++) { SQLiteCommand.BindParameter(sqlitePlatform.SQLiteApi, Statement, i + 1, source[i], Connection.StoreDateTimeAsTicks, Connection.Serializer); } } Result r; lock (_locker) { r = sqlitePlatform.SQLiteApi.Step(Statement); } if (r == Result.Done) { var rowsAffected = sqlitePlatform.SQLiteApi.Changes(Connection.Handle); sqlitePlatform.SQLiteApi.Reset(Statement); return(rowsAffected); } if (r == Result.Error) { var msg = sqlitePlatform.SQLiteApi.Errmsg16(Connection.Handle); sqlitePlatform.SQLiteApi.Reset(Statement); throw SQLiteException.New(r, msg); } if (r == Result.Constraint && sqlitePlatform.SQLiteApi.ExtendedErrCode(Connection.Handle) == ExtendedResult.ConstraintNotNull) { sqlitePlatform.SQLiteApi.Reset(Statement); throw NotNullConstraintViolationException.New(r, sqlitePlatform.SQLiteApi.Errmsg16(Connection.Handle)); } sqlitePlatform.SQLiteApi.Reset(Statement); throw SQLiteException.New(r, r.ToString()); }