コード例 #1
0
        internal SQLiteStatement GetStatement(int index)
        {
            // Haven't built any statements yet
            if (_statementList == null)
            {
                return(BuildNextCommand());
            }

            // If we're at the last built statement and want the next unbuilt statement, then build it
            if (index == _statementList.Count)
            {
                if (String.IsNullOrEmpty(_remainingText) == false)
                {
                    return(BuildNextCommand());
                }
                else
                {
                    return(null); // No more commands
                }
            }

            SQLiteStatement stmt = _statementList[index];

            stmt.BindParameters();

            return(stmt);
        }
コード例 #2
0
ファイル: SQLite3.cs プロジェクト: bdcliang/BD
        internal override int Reset(SQLiteStatement stmt)
        {
            int errorCode = UnsafeNativeMethods.sqlite3_reset_interop((IntPtr)stmt._sqlite_stmt);

            switch (errorCode)
            {
            case 0x11:
                string str;
                using (SQLiteStatement statement = this.Prepare(null, stmt._sqlStatement, null, (uint)(stmt._command._commandTimeout * 0x3e8), out str))
                {
                    stmt._sqlite_stmt.Dispose();
                    stmt._sqlite_stmt      = statement._sqlite_stmt;
                    statement._sqlite_stmt = null;
                    stmt.BindParameters();
                }
                return(-1);

            case 6:
            case 5:
                return(errorCode);
            }
            if (errorCode > 0)
            {
                throw new SQLiteException(errorCode, this.SQLiteLastError());
            }
            return(0);
        }
コード例 #3
0
        /// <summary>
        /// Builds an array of prepared statements for each complete SQL statement in the command text
        /// </summary>
        internal SQLiteStatement BuildNextCommand()
        {
            SQLiteStatement stmt = null;

            try
            {
                if ((_cnn != null) && (_cnn._sql != null))
                {
                    if (_statementList == null)
                    {
                        _remainingText = _commandText;
                    }

                    stmt = _cnn._sql.Prepare(_cnn, _remainingText, (_statementList == null) ? null : _statementList[_statementList.Count - 1], (uint)(_commandTimeout * 1000), out _remainingText);

                    if (stmt != null)
                    {
                        stmt._command = this;

                        if (_statementList == null)
                        {
                            _statementList = new List <SQLiteStatement>();
                        }

                        _statementList.Add(stmt);

                        _parameterCollection.MapParameters(stmt);
                        stmt.BindParameters();
                    }
                }
                return(stmt);
            }
            catch (Exception)
            {
                if (stmt != null)
                {
                    if ((_statementList != null) && _statementList.Contains(stmt))
                    {
                        _statementList.Remove(stmt);
                    }

                    stmt.Dispose();
                }

                // If we threw an error compiling the statement, we cannot continue on so set the remaining text to null.
                _remainingText = null;

                throw;
            }
        }
コード例 #4
0
        internal SQLiteStatement GetStatement(int index)
        {
            if (this._statementList == null)
            {
                return(this.BuildNextCommand());
            }
            if (index == this._statementList.Count)
            {
                if (!string.IsNullOrEmpty(this._remainingText))
                {
                    return(this.BuildNextCommand());
                }
                return(null);
            }
            SQLiteStatement statement = this._statementList[index];

            statement.BindParameters();
            return(statement);
        }
コード例 #5
0
        internal SQLiteStatement BuildNextCommand()
        {
            SQLiteStatement item = null;
            SQLiteStatement statement2;

            try
            {
                if (this._statementList == null)
                {
                    this._remainingText = this._commandText;
                }
                item = this._cnn._sql.Prepare(this._cnn, this._remainingText, (this._statementList == null) ? null : this._statementList[this._statementList.Count - 1], (uint)(this._commandTimeout * 0x3e8), out this._remainingText);
                if (item != null)
                {
                    item._command = this;
                    if (this._statementList == null)
                    {
                        this._statementList = new List <SQLiteStatement>();
                    }
                    this._statementList.Add(item);
                    this._parameterCollection.MapParameters(item);
                    item.BindParameters();
                }
                statement2 = item;
            }
            catch (Exception)
            {
                if (item != null)
                {
                    if (this._statementList.Contains(item))
                    {
                        this._statementList.Remove(item);
                    }
                    item.Dispose();
                }
                this._remainingText = null;
                throw;
            }
            return(statement2);
        }
コード例 #6
0
ファイル: SQLite3.cs プロジェクト: kanta-mir/SQLite-Source
        internal override int Reset(SQLiteStatement stmt)
        {
            int n;

#if !SQLITE_STANDARD
            n = UnsafeNativeMethods.sqlite3_reset_interop(stmt._sqlite_stmt);
#else
            n = UnsafeNativeMethods.sqlite3_reset(stmt._sqlite_stmt);
#endif

            // If the schema changed, try and re-prepare it
            if (n == 17) // SQLITE_SCHEMA
            {
                // Recreate a dummy statement
                string str;
                using (SQLiteStatement tmp = Prepare(null, stmt._sqlStatement, null, (uint)(stmt._command._commandTimeout * 1000), out str))
                {
                    // Finalize the existing statement
                    stmt._sqlite_stmt.Dispose();
                    // Reassign a new statement pointer to the old statement and clear the temporary one
                    stmt._sqlite_stmt = tmp._sqlite_stmt;
                    tmp._sqlite_stmt  = null;

                    // Reapply parameters
                    stmt.BindParameters();
                }
                return(-1);            // Reset was OK, with schema change
            }
            else if (n == 6 || n == 5) // SQLITE_LOCKED || SQLITE_BUSY
            {
                return(n);
            }

            if (n > 0)
            {
                throw new SQLiteException(n, SQLiteLastError());
            }

            return(0); // We reset OK, no schema changes
        }
コード例 #7
0
        internal override int Reset(SQLiteStatement stmt)
        {
            int n;

            n = UnsafeNativeMethods.sqlite3_reset_interop(stmt._sqlite_stmt);

            // If the schema changed, try and re-prepare it
            if (n == 17) // SQLITE_SCHEMA
            {
                // Recreate a dummy statement
                string str;
                using (SQLiteStatement tmp = Prepare(stmt._sqlStatement, null, out str))
                {
                    // Finalize the existing statement
                    FinalizeStatement(stmt);

                    // Reassign a new statement pointer to the old statement and clear the temporary one
                    stmt._sqlite_stmt = tmp._sqlite_stmt;
                    tmp._sqlite_stmt  = IntPtr.Zero;

                    // Reapply parameters
                    stmt.BindParameters();
                }
                return(-1);  // Reset was OK, with schema change
            }
            else if (n == 6) // SQLITE_LOCKED
            {
                return(n);
            }

            if (n > 0)
            {
                throw new SQLiteException(n, SQLiteLastError());
            }

            return(0); // We reset OK, no schema changes
        }
コード例 #8
0
    internal override int Reset(SQLiteStatement stmt)
    {
      int n;

#if !SQLITE_STANDARD
      n = UnsafeNativeMethods.sqlite3_reset_interop(stmt._sqlite_stmt);
#else
      n = UnsafeNativeMethods.sqlite3_reset(stmt._sqlite_stmt);
#endif

      // If the schema changed, try and re-prepare it
      if (n == 17) // SQLITE_SCHEMA
      {
        // Recreate a dummy statement
        string str;
        using (SQLiteStatement tmp = Prepare(null, stmt._sqlStatement, null, (uint)(stmt._command._commandTimeout * 1000), out str))
        {
          // Finalize the existing statement
          stmt._sqlite_stmt.Dispose();
          // Reassign a new statement pointer to the old statement and clear the temporary one
          stmt._sqlite_stmt = tmp._sqlite_stmt;
          tmp._sqlite_stmt = null;

          // Reapply parameters
          stmt.BindParameters();
        }
        return -1; // Reset was OK, with schema change
      }
      else if (n == 6 || n == 5) // SQLITE_LOCKED || SQLITE_BUSY
        return n;

      if (n > 0)
        throw new SQLiteException(n, GetLastError());

      return 0; // We reset OK, no schema changes
    }
コード例 #9
0
ファイル: SQLite3.cs プロジェクト: CuneytKukrer/TestProject
    internal override SQLiteErrorCode Reset(SQLiteStatement stmt)
    {
      SQLiteErrorCode n;

#if !SQLITE_STANDARD
      n = UnsafeNativeMethods.sqlite3_reset_interop(stmt._sqlite_stmt);
#else
      n = UnsafeNativeMethods.sqlite3_reset(stmt._sqlite_stmt);
#endif

      // If the schema changed, try and re-prepare it
      if (n == SQLiteErrorCode.Schema)
      {
        // Recreate a dummy statement
        string str;
        using (SQLiteStatement tmp = Prepare(null, stmt._sqlStatement, null, (uint)(stmt._command._commandTimeout * 1000), out str))
        {
          // Finalize the existing statement
          stmt._sqlite_stmt.Dispose();
          // Reassign a new statement pointer to the old statement and clear the temporary one
          stmt._sqlite_stmt = tmp._sqlite_stmt;
          tmp._sqlite_stmt = null;

          // Reapply parameters
          stmt.BindParameters();
        }
        return (SQLiteErrorCode)(-1); // Reset was OK, with schema change
      }
      else if (n == SQLiteErrorCode.Locked || n == SQLiteErrorCode.Busy)
        return n;

      if (n != SQLiteErrorCode.Ok)
        throw new SQLiteException(n, GetLastError());

      return SQLiteErrorCode.Ok; // We reset OK, no schema changes
    }
コード例 #10
0
ファイル: SQLite3.cs プロジェクト: ronnyMakhuddin/SharperNLP
        internal override int Reset(SQLiteStatement stmt)
        {
            int n;

              n = UnsafeNativeMethods.sqlite3_reset_interop(stmt._sqlite_stmt);

              // If the schema changed, try and re-prepare it
              if (n == 17) // SQLITE_SCHEMA
              {
            // Recreate a dummy statement
            string str;
            using (SQLiteStatement tmp = Prepare(stmt._sqlStatement, null, out str))
            {
              // Finalize the existing statement
              FinalizeStatement(stmt);

              // Reassign a new statement pointer to the old statement and clear the temporary one
              stmt._sqlite_stmt = tmp._sqlite_stmt;
              tmp._sqlite_stmt = IntPtr.Zero;

              // Reapply parameters
              stmt.BindParameters();
            }
            return -1; // Reset was OK, with schema change
              }
              else if (n == 6) // SQLITE_LOCKED
            return n;

              if (n > 0)
            throw new SQLiteException(n, SQLiteLastError());

              return 0; // We reset OK, no schema changes
        }