Exemple #1
0
        public int ExecuteNonQuery()
        {
            int result = 0;

            for (int i = 0; i < _Statements.Count; ++i)
            {
                SQLiteStatement statement = _Statements[i];

                statement.Compile();

                _Connection.NativeMethods.busy_timeout(_Timeout);

                SQLiteCode res = statement.Step();

                if (res == SQLiteCode.Done || res == SQLiteCode.RowReady)
                {
                    statement.Reset();

                    result += _Connection.LastChangesCount;
                }
                else if (res == SQLiteCode.Error)
                {
                    statement.Dispose(); // UnCompile will throw exception with appropriate msg.
                }
                else
                {
                    throw new SQLiteException("Unknown SQLite error");
                }
            }

            return(result);
        }
Exemple #2
0
        private void ExecuteFirstStep()
        {
            _Done      = true;
            _FirstRead = true;

            // Exec first step and get column info.
            _Statement = _Command.Statements[_StatementIndex];
            _Statement.Compile();
            _NativeMethods.busy_timeout(_Command.CommandTimeout);

            SQLiteCode res = _Statement.Step();

            if (res == SQLiteCode.RowReady || res == SQLiteCode.Done)
            {
                _FieldNames             = new String[_Statement.GetColumnCount()];
                _FieldTypes             = new Type[_Statement.GetColumnCount()];
                _ColumnNameStartIndexes = new int[_Statement.GetColumnCount()];

                // Get column info.
                for (int i = 0; i < _Statement.GetColumnCount(); i++)
                {
                    _FieldNames[i]             = _Statement.GetColumnName(i);
                    _FieldTypes[i]             = SQLType2Type(_Statement.GetColumnType(i));
                    _ColumnNameStartIndexes[i] = _FieldNames[i].IndexOf('.') + 1;
                }

                _Done = res == SQLiteCode.Done;
            }
            else if (res == SQLiteCode.Error)
            {
                _Statement.Dispose();
            }
            else
            {
                throw new SQLiteException(string.Format("Unknown SQLite error code {0}.", res));
            }
        }
        private void ExecuteFirstStep()
        {
            _Done = true;
            _FirstRead = true;

            // Exec first step and get column info.
            _Statement = _Command.Statements[_StatementIndex];
            _Statement.Compile();
            _NativeMethods.busy_timeout(_Command.CommandTimeout);

            SQLiteCode res = _Statement.Step();
            if (res == SQLiteCode.RowReady || res == SQLiteCode.Done)
            {
                _FieldNames = new String[_Statement.GetColumnCount()];
                _FieldTypes = new Type[_Statement.GetColumnCount()];
                _ColumnNameStartIndexes = new int[_Statement.GetColumnCount()];

                // Get column info.
                for (int i = 0; i < _Statement.GetColumnCount(); i++)
                {
                    _FieldNames[i] = _Statement.GetColumnName(i);
                    _FieldTypes[i] = SQLType2Type(_Statement.GetColumnType(i));
                    _ColumnNameStartIndexes[i] = _FieldNames[i].IndexOf('.') + 1;
                }

                _Done = res == SQLiteCode.Done;
            }
            else if (res == SQLiteCode.Error) _Statement.Dispose();
            else throw new SQLiteException(string.Format("Unknown SQLite error code {0}.", res));
        }