Exemple #1
0
        /// <summary>
        /// Builds an array of prepared statements for each complete SQL statement in the command text
        /// </summary>
        internal SQLiteStatement BuildNextCommand()
        {
            SQLiteStatement stmt;

            try
            {
                if (_statementList == null)
                {
                    _remainingText = _commandText;
                }

                stmt = _cnn._sql.Prepare(_remainingText, (_statementList == null) ? null : _statementList[_statementList.Count - 1], 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)
            {
                ClearCommands();
                throw;
            }
        }
Exemple #2
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;
            }
        }