public int ExecuteNonQuery() { if (this._conn.Trace) { Console.WriteLine("Executing: " + this); } var r = SQLite3.Result.OK; var stmt = this.Prepare(); r = SQLite3.Step(stmt); this.Finalize(stmt); if (r == SQLite3.Result.Done) { int rowsAffected = SQLite3.Changes(this._conn.Handle); return(rowsAffected); } else if (r == SQLite3.Result.Error) { string msg = SQLite3.GetErrmsg(this._conn.Handle); throw SQLiteException.New(r, msg); } else { throw SQLiteException.New(r, r.ToString()); } }
public int ExecuteNonQuery(object[] source) { if (this.Connection.Trace) { Console.WriteLine("Executing: " + this.CommandText); } var r = SQLite3.Result.OK; if (!this.Initialized) { this.Statement = this.Prepare(); this.Initialized = true; } //bind the values. if (source != null) { for (int i = 0; i < source.Length; i++) { SQLiteCommand.BindParameter(this.Statement, i + 1, source[i]); } } r = SQLite3.Step(this.Statement); if (r == SQLite3.Result.Done) { int rowsAffected = SQLite3.Changes(this.Connection.Handle); SQLite3.Reset(this.Statement); return(rowsAffected); } else if (r == SQLite3.Result.Error) { string msg = SQLite3.GetErrmsg(this.Connection.Handle); SQLite3.Reset(this.Statement); throw SQLiteException.New(r, msg); } else { SQLite3.Reset(this.Statement); throw SQLiteException.New(r, r.ToString()); } }