Esempio n. 1
0
        public int ExecuteNonQuery()
        {
            var r = SQLite3.Result.OK;

            for (int i = 0; i < _conn.MaxExecuteAttempts; i++)
            {
                var stmt = Prepare();
                r = SQLite3.Step(stmt);
                SQLite3.Finalize(stmt);
                if (r == SQLite3.Result.Error)
                {
                    string msg = SQLite3.Errmsg(_conn.Handle);
                    throw SQLiteException.New(r, msg);
                }
                else if (r == SQLite3.Result.Done)
                {
                    int rowsAffected = SQLite3.Changes(_conn.Handle);
                    return(rowsAffected);
                }
                else if (r == SQLite3.Result.Busy)
                {
                    // We will retry
                    System.Threading.Thread.Sleep(1000);
                }
                else
                {
                    throw SQLiteException.New(r, r.ToString());
                }
            }
            throw SQLiteException.New(r, r.ToString());
        }
Esempio n. 2
0
        public int ExecuteNonQuery()
        {
            var stmt = Prepare();

            var r = SQLite3.Step(stmt);

            if (r == SQLite3.Result.Error)
            {
                string msg = SQLite3.Errmsg(_db);
                SQLite3.Finalize(stmt);
                throw SQLiteException.New(r, msg);
            }
            else if (r == SQLite3.Result.Done)
            {
                int rowsAffected = SQLite3.Changes(_db);
                SQLite3.Finalize(stmt);
                return(rowsAffected);
            }
            else
            {
                SQLite3.Finalize(stmt);
                throw SQLiteException.New(r, "Unknown error");
            }
        }