Exemplo n.º 1
0
        internal SQLiteStatement(SQLiteBase sqlbase, SQLiteConnectionFlags flags, SQLiteStatementHandle stmt, string strCommand, SQLiteStatement previous)
        {
            this._sql          = sqlbase;
            this._sqlite_stmt  = stmt;
            this._sqlStatement = strCommand;
            this._flags        = flags;
            int num  = 0;
            int num1 = this._sql.Bind_ParamCount(this, this._flags);

            if (num1 > 0)
            {
                if (previous != null)
                {
                    num = previous._unnamedParameters;
                }
                this._paramNames  = new string[num1];
                this._paramValues = new SQLiteParameter[num1];
                for (int i = 0; i < num1; i++)
                {
                    string str = this._sql.Bind_ParamName(this, this._flags, i + 1);
                    if (string.IsNullOrEmpty(str))
                    {
                        CultureInfo invariantCulture = CultureInfo.InvariantCulture;
                        object[]    objArray         = new object[] { num };
                        str = HelperMethods.StringFormat(invariantCulture, ";{0}", objArray);
                        num++;
                        this._unnamedParameters++;
                    }
                    this._paramNames[i]  = str;
                    this._paramValues[i] = null;
                }
            }
        }
        internal override void Bind_Text(SQLiteStatement stmt, SQLiteConnectionFlags flags, int index, string value)
        {
            SQLiteStatementHandle _sqliteStmt = stmt._sqlite_stmt;

            if (HelperMethods.LogBind(flags))
            {
                SQLite3.LogBind(_sqliteStmt, index, value);
            }
            SQLiteErrorCode sQLiteErrorCode = UnsafeNativeMethods.sqlite3_bind_text16(_sqliteStmt, index, value, value.Length * 2, (IntPtr)(-1));

            if (sQLiteErrorCode != SQLiteErrorCode.Ok)
            {
                throw new SQLiteException(sQLiteErrorCode, this.GetLastError());
            }
        }
Exemplo n.º 3
0
 private void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             if (this._sqlite_stmt != null)
             {
                 this._sqlite_stmt.Dispose();
                 this._sqlite_stmt = null;
             }
             this._paramNames   = null;
             this._paramValues  = null;
             this._sql          = null;
             this._sqlStatement = null;
         }
         this.disposed = true;
     }
 }
Exemplo n.º 4
0
        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());
            }
        }