コード例 #1
0
 protected override void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         try
         {
             if (disposing)
             {
                 Release();
                 Clear();
                 _db              = null;
                 _fields          = null;
                 _parameters      = null;
                 _transaction     = null;
                 _outputParams    = null;
                 _statusVector    = null;
                 _allRowsFetched  = false;
                 _state           = StatementState.Deallocated;
                 _statementType   = DbStatementType.None;
                 _recordsAffected = 0;
                 _handle.Dispose();
                 FetchSize = 0;
             }
         }
         finally
         {
             _disposed = true;
             base.Dispose(disposing);
         }
     }
 }
コード例 #2
0
        protected DbStatementType ProcessStatementTypeInfoBuffer(byte[] buffer)
        {
            DbStatementType stmtType = DbStatementType.None;
            int             pos      = 0;
            int             length   = 0;
            int             type     = 0;

            while ((type = buffer[pos++]) != IscCodes.isc_info_end)
            {
                length = IscHelper.VaxInteger(buffer, pos, 2);
                pos   += 2;
                switch (type)
                {
                case IscCodes.isc_info_sql_stmt_type:
                    stmtType = (DbStatementType)IscHelper.VaxInteger(buffer, pos, length);
                    pos     += length;
                    break;

                default:
                    pos += length;
                    break;
                }
            }

            return(stmtType);
        }
コード例 #3
0
        public override void Prepare(string commandText)
        {
            ClearAll();

            try
            {
                if (_state == StatementState.Deallocated)
                {
                    SendAllocateToBuffer();
                    _database.XdrStream.Flush();
                    ProcessAllocateResponce(_database.ReadGenericResponse());
                }

                SendPrepareToBuffer(commandText);
                _database.XdrStream.Flush();
                ProcessPrepareResponse(_database.ReadGenericResponse());

                SendInfoSqlToBuffer(StatementTypeInfoItems, IscCodes.STATEMENT_TYPE_BUFFER_SIZE);
                _database.XdrStream.Flush();
                _statementType = ProcessStatementTypeInfoBuffer(ProcessInfoSqlResponse(_database.ReadGenericResponse()));


                _state = StatementState.Prepared;
            }
            catch (IOException ex)
            {
                if (_state == StatementState.Allocated)
                {
                    _state = StatementState.Error;
                }
                throw IscException.ForErrorCode(IscCodes.isc_net_read_err, ex);
            }
        }
コード例 #4
0
 protected void ProcessAllocateResponce(GenericResponse response)
 {
     _handle         = response.ObjectHandle;
     _allRowsFetched = false;
     _state          = StatementState.Allocated;
     _statementType  = DbStatementType.None;
 }
コード例 #5
0
        public override void Prepare(string commandText)
        {
            ClearAll();

            ClearStatusVector();

            if (_state == StatementState.Deallocated)
            {
                Allocate();
            }

            _fields = new Descriptor(1);

            var sqlda    = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _fields);
            var trHandle = _transaction.HandlePtr;

            var buffer = _db.Charset.GetBytes(commandText);

            _db.FbClient.isc_dsql_prepare(
                _statusVector,
                ref trHandle,
                ref _handle,
                (short)buffer.Length,
                buffer,
                _db.Dialect,
                sqlda);

            var descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda);

            XsqldaMarshaler.CleanUpNativeData(ref sqlda);

            _db.ProcessStatusVector(_statusVector);

            _fields = descriptor;

            if (_fields.ActualCount > 0 && _fields.ActualCount != _fields.Count)
            {
                Describe();
            }
            else
            {
                if (_fields.ActualCount == 0)
                {
                    _fields = new Descriptor(0);
                }
            }

            _fields.ResetValues();

            _statementType = GetStatementType();

            _state = StatementState.Prepared;
        }
コード例 #6
0
        private void Allocate()
        {
            ClearStatusVector();

            var dbHandle = _db.HandlePtr;

            _db.FbClient.isc_dsql_allocate_statement(
                _statusVector,
                ref dbHandle,
                ref _handle);

            _db.ProcessStatusVector(_statusVector);

            _allRowsFetched = false;
            _state          = StatementState.Allocated;
            _statementType  = DbStatementType.None;
        }
コード例 #7
0
ファイル: GdsStatement.cs プロジェクト: raj581/Marvin
        public override void Prepare(string commandText)
        {
            // Clear data
            this.Clear();
            this.parameters = null;
            this.fields     = null;

            lock (this.db)
            {
                if (this.state == StatementState.Deallocated)
                {
                    // Allocate	statement
                    this.Allocate();
                }

                try
                {
                    this.db.Send.Write(IscCodes.op_prepare_statement);
                    this.db.Send.Write(this.transaction.Handle);
                    this.db.Send.Write(this.handle);
                    this.db.Send.Write((int)this.db.Dialect);
                    this.db.Send.Write(commandText);
                    this.db.Send.WriteBuffer(DescribeInfoItems, DescribeInfoItems.Length);
                    this.db.Send.Write(IscCodes.MAX_BUFFER_SIZE);
                    this.db.Send.Flush();

                    GdsResponse r = this.db.ReadGenericResponse();
                    this.fields = this.ParseSqlInfo(r.Data, DescribeInfoItems);

                    // Determine the statement type
                    this.statementType = this.GetStatementType();

                    this.state = StatementState.Prepared;
                }
                catch (IOException)
                {
                    this.state = StatementState.Error;
                    throw new IscException(IscCodes.isc_net_read_err);
                }
            }
        }
コード例 #8
0
        private void Allocate()
        {
            lock (_db)
            {
                // Clear the status vector
                ClearStatusVector();

                DatabaseHandle dbHandle = _db.HandlePtr;

                _db.FbClient.isc_dsql_allocate_statement(
                    _statusVector,
                    ref dbHandle,
                    ref _handle);

                _db.ProcessStatusVector(_statusVector);

                _allRowsFetched = false;
                _state          = StatementState.Allocated;
                _statementType  = DbStatementType.None;
            }
        }
コード例 #9
0
        private void Allocate()
        {
            lock (this.db)
            {
                int[] statusVector = ExtConnection.GetNewStatusVector();
                int   dbHandle     = this.db.Handle;
                int   stmtHandle   = this.handle;

                SafeNativeMethods.isc_dsql_allocate_statement(
                    statusVector,
                    ref dbHandle,
                    ref stmtHandle);

                this.db.ParseStatusVector(statusVector);

                this.handle         = stmtHandle;
                this.allRowsFetched = false;
                this.state          = StatementState.Allocated;
                this.statementType  = DbStatementType.None;
            }
        }
コード例 #10
0
        protected override void Dispose(bool disposing)
        {
            lock (this)
            {
                if (!IsDisposed)
                {
                    try
                    {
                        // release any unmanaged resources
                        Release();
                    }
                    catch
                    {
                    }
                    finally
                    {
                        // release any managed resources
                        if (disposing)
                        {
                            Clear();

                            _rows           = null;
                            _outputParams   = null;
                            _database       = null;
                            _fields         = null;
                            _parameters     = null;
                            _transaction    = null;
                            _allRowsFetched = false;
                            _state          = StatementState.Deallocated;
                            _statementType  = DbStatementType.None;
                            _handle         = 0;
                            _fetchSize      = 0;
                            RecordsAffected = 0;
                        }

                        base.Dispose(disposing);
                    }
                }
            }
        }
コード例 #11
0
        public override void Prepare(string commandText)
        {
            // Clear data
            ClearAll();

            lock (_database.SyncObject)
            {
                try
                {
                    if (_state == StatementState.Deallocated)
                    {
                        // Allocate statement
                        SendAllocateToBuffer();
                        _database.XdrStream.Flush();
                        ProcessAllocateResponce(_database.ReadGenericResponse());
                    }

                    SendPrepareToBuffer(commandText);
                    _database.XdrStream.Flush();
                    ProcessPrepareResponse(_database.ReadGenericResponse());

                    // Grab statement type
                    SendInfoSqlToBuffer(StatementTypeInfoItems, IscCodes.STATEMENT_TYPE_BUFFER_SIZE);
                    _database.XdrStream.Flush();
                    _statementType = ProcessStatementTypeInfoBuffer(ProcessInfoSqlResponse(_database.ReadGenericResponse()));


                    _state = StatementState.Prepared;
                }
                catch (IOException ex)
                {
                    // if the statement has been already allocated, it's now in error
                    if (_state == StatementState.Allocated)
                    {
                        _state = StatementState.Error;
                    }
                    throw IscException.ForErrorCode(IscCodes.isc_net_read_err, ex);
                }
            }
        }
コード例 #12
0
        protected override void Dispose(bool disposing)
        {
            lock (this)
            {
                if (!this.IsDisposed)
                {
                    try
                    {
                        // release any unmanaged resources
                        this.Release();
                    }
                    catch
                    {
                    }
                    finally
                    {
                        // release any managed resources
                        if (disposing)
                        {
                            this.Clear();

                            this.rows            = null;
                            this.outputParams    = null;
                            this.database        = null;
                            this.fields          = null;
                            this.parameters      = null;
                            this.transaction     = null;
                            this.allRowsFetched  = false;
                            this.state           = StatementState.Deallocated;
                            this.statementType   = DbStatementType.None;
                            this.handle          = 0;
                            this.fetchSize       = 0;
                            this.RecordsAffected = 0;
                        }

                        base.Dispose(disposing);
                    }
                }
            }
        }
コード例 #13
0
        public override void Prepare(string commandText)
        {
            // Clear data
            this.ClearAll();

            lock (this.database.SyncObject)
            {
                try
                {
                    if (this.state == StatementState.Deallocated)
                    {
                        // Allocate	statement
                        this.SendAllocateToBuffer();
                        this.database.Flush();
                        this.ProcessAllocateResponce(this.database.ReadGenericResponse());
                    }

                    this.SendPrepareToBuffer(commandText);
                    this.database.Flush();
                    this.ProcessPrepareResponse(this.database.ReadGenericResponse());

                    // Grab statement type
                    this.SendInfoSqlToBuffer(StatementTypeInfoItems, IscCodes.STATEMENT_TYPE_BUFFER_SIZE);
                    this.database.Flush();
                    this.statementType = this.ProcessStatementTypeInfoBuffer(this.ProcessInfoSqlResponse(this.database.ReadGenericResponse()));


                    this.state = StatementState.Prepared;
                }
                catch (IOException)
                {
                    // if the statement has been already allocated, it's now in error
                    if (this.state == StatementState.Allocated)
                    {
                        this.state = StatementState.Error;
                    }
                    throw new IscException(IscCodes.isc_net_read_err);
                }
            }
        }
コード例 #14
0
 public override void Dispose()
 {
     if (!_disposed)
     {
         _disposed = true;
         Release();
         Clear();
         _rows           = null;
         _outputParams   = null;
         _database       = null;
         _fields         = null;
         _parameters     = null;
         _transaction    = null;
         _allRowsFetched = false;
         _state          = StatementState.Deallocated;
         _statementType  = DbStatementType.None;
         _handle         = 0;
         _fetchSize      = 0;
         RecordsAffected = 0;
         base.Dispose();
     }
 }
コード例 #15
0
ファイル: GdsStatement.cs プロジェクト: raj581/Marvin
        private void Allocate()
        {
            lock (this.db)
            {
                try
                {
                    this.db.Send.Write(IscCodes.op_allocate_statement);
                    this.db.Send.Write(this.db.Handle);
                    this.db.Send.Flush();

                    this.handle         = this.db.ReadGenericResponse().ObjectHandle;
                    this.allRowsFetched = false;
                    this.state          = StatementState.Allocated;
                    this.statementType  = DbStatementType.None;
                }
                catch (IOException)
                {
                    this.state = StatementState.Deallocated;
                    throw new IscException(IscCodes.isc_net_read_err);
                }
            }
        }
コード例 #16
0
        private void Allocate()
        {
            lock (this.db)
            {
                // Clear the status vector
                this.ClearStatusVector();

                int dbHandle   = this.db.Handle;
                int stmtHandle = this.handle;

                db.FbClient.isc_dsql_allocate_statement(
                    this.statusVector,
                    ref dbHandle,
                    ref stmtHandle);

                this.db.ParseStatusVector(this.statusVector);

                this.handle         = stmtHandle;
                this.allRowsFetched = false;
                this.state          = StatementState.Allocated;
                this.statementType  = DbStatementType.None;
            }
        }
コード例 #17
0
        private void Allocate()
        {
            lock (_db)
            {
                // Clear the status vector
                ClearStatusVector();

                int dbHandle   = _db.Handle;
                int stmtHandle = _handle;

                _db.FbClient.isc_dsql_allocate_statement(
                    _statusVector,
                    ref dbHandle,
                    ref stmtHandle);

                _db.ParseStatusVector(_statusVector);

                _handle         = stmtHandle;
                _allRowsFetched = false;
                _state          = StatementState.Allocated;
                _statementType  = DbStatementType.None;
            }
        }
コード例 #18
0
ファイル: GdsStatement.cs プロジェクト: cafee/NETProvider
		protected void ProcessAllocateResponce(GenericResponse response)
		{
			this.handle = response.ObjectHandle;
			this.allRowsFetched = false;
			this.state = StatementState.Allocated;
			this.statementType = DbStatementType.None;
		}
コード例 #19
0
        public override void Prepare(string commandText)
        {
            // Clear data
            ClearAll();

            lock (_db)
            {
                // Clear the status vector
                ClearStatusVector();

                // Allocate the statement if needed
                if (_state == StatementState.Deallocated)
                {
                    Allocate();
                }

                // Marshal structures to pointer


                // Setup fields	structure
                _fields = new Descriptor(1);

                IntPtr            sqlda    = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _fields);
                TransactionHandle trHandle = _transaction.HandlePtr;

                byte[] buffer = _db.Charset.GetBytes(commandText);

                _db.FbClient.isc_dsql_prepare(
                    _statusVector,
                    ref trHandle,
                    ref _handle,
                    (short)buffer.Length,
                    buffer,
                    _db.Dialect,
                    sqlda);

                // Marshal Pointer
                Descriptor descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda);

                // Free	memory
                XsqldaMarshaler.CleanUpNativeData(ref sqlda);

                // Parse status	vector
                _db.ProcessStatusVector(_statusVector);

                // Describe	fields
                _fields = descriptor;

                if (_fields.ActualCount > 0 && _fields.ActualCount != _fields.Count)
                {
                    Describe();
                }
                else
                {
                    if (_fields.ActualCount == 0)
                    {
                        _fields = new Descriptor(0);
                    }
                }

                // Reset actual	field values
                _fields.ResetValues();

                // Get Statement type
                _statementType = GetStatementType();

                // Update state
                _state = StatementState.Prepared;
            }
        }
コード例 #20
0
        public override void Prepare(string commandText)
        {
            // Clear data
            this.ClearAll();

            lock (this.db)
            {
                if (this.state == StatementState.Deallocated)
                {
                    // Allocate	statement
                    this.Allocate();
                }

                // Marshal structures to pointer
                XsqldaMarshaler marshaler = XsqldaMarshaler.Instance;

                // Setup fields	structure
                this.fields = new Descriptor(1);

                IntPtr sqlda = marshaler.MarshalManagedToNative(this.db.Charset, this.fields);

                int[] statusVector = ExtConnection.GetNewStatusVector();
                int   trHandle     = this.transaction.Handle;
                int   stmtHandle   = this.handle;

                byte[] buffer = this.db.Charset.GetBytes(commandText);

                SafeNativeMethods.isc_dsql_prepare(
                    statusVector,
                    ref trHandle,
                    ref stmtHandle,
                    (short)buffer.Length,
                    buffer,
                    this.db.Dialect,
                    sqlda);

                // Marshal Pointer
                Descriptor descriptor = marshaler.MarshalNativeToManaged(this.db.Charset, sqlda);

                // Free	memory
                marshaler.CleanUpNativeData(ref sqlda);

                // Parse status	vector
                this.db.ParseStatusVector(statusVector);

                // Describe	fields
                this.fields = descriptor;
                if (this.fields.ActualCount > 0 && this.fields.ActualCount != this.fields.Count)
                {
                    this.Describe();
                }
                else
                {
                    if (this.fields.ActualCount == 0)
                    {
                        this.fields = new Descriptor(0);
                    }
                }

                // Reset actual	field values
                this.fields.ResetValues();

                // Get Statement type
                this.statementType = this.GetStatementType();

                // Update state
                this.state = StatementState.Prepared;
            }
        }
コード例 #21
0
ファイル: ExtStatement.cs プロジェクト: kingpong/NETProvider
        private void Allocate()
        {
            lock (this.db)
            {
                int[] statusVector = ExtConnection.GetNewStatusVector();
                int dbHandle = this.db.Handle;
                int stmtHandle = this.handle;

                SafeNativeMethods.isc_dsql_allocate_statement(
                    statusVector,
                    ref	dbHandle,
                    ref	stmtHandle);

                this.db.ParseStatusVector(statusVector);

                this.handle = stmtHandle;
                this.allRowsFetched = false;
                this.state = StatementState.Allocated;
                this.statementType = DbStatementType.None;
            }
        }
コード例 #22
0
ファイル: ExtStatement.cs プロジェクト: kingpong/NETProvider
        public override void Prepare(string commandText)
        {
            // Clear data
            this.ClearAll();

            lock (this.db)
            {
                if (this.state == StatementState.Deallocated)
                {
                    // Allocate	statement
                    this.Allocate();
                }

                // Marshal structures to pointer
                XsqldaMarshaler marshaler = XsqldaMarshaler.Instance;

                // Setup fields	structure
                this.fields = new Descriptor(1);

                IntPtr sqlda = marshaler.MarshalManagedToNative(this.db.Charset, this.fields);

                int[] statusVector = ExtConnection.GetNewStatusVector();
                int trHandle = this.transaction.Handle;
                int stmtHandle = this.handle;

                byte[] buffer = this.db.Charset.GetBytes(commandText);

                SafeNativeMethods.isc_dsql_prepare(
                    statusVector,
                    ref	trHandle,
                    ref	stmtHandle,
                    (short)buffer.Length,
                    buffer,
                    this.db.Dialect,
                    sqlda);

                // Marshal Pointer
                Descriptor descriptor = marshaler.MarshalNativeToManaged(this.db.Charset, sqlda);

                // Free	memory
                marshaler.CleanUpNativeData(ref	sqlda);

                // Parse status	vector
                this.db.ParseStatusVector(statusVector);

                // Describe	fields
                this.fields = descriptor;
                if (this.fields.ActualCount > 0 && this.fields.ActualCount != this.fields.Count)
                {
                    this.Describe();
                }
                else
                {
                    if (this.fields.ActualCount == 0)
                    {
                        this.fields = new Descriptor(0);
                    }
                }

                // Reset actual	field values
                this.fields.ResetValues();

                // Get Statement type
                this.statementType = this.GetStatementType();

                // Update state
                this.state = StatementState.Prepared;
            }
        }
コード例 #23
0
		public override void Prepare(string commandText)
		{
			// Clear data
			this.Clear();
			this.parameters = null;
			this.fields = null;

			lock (this.db)
			{
				if (this.state == StatementState.Deallocated)
				{
					// Allocate	statement
					this.Allocate();
				}

				try
				{
					this.db.Send.Write(IscCodes.op_prepare_statement);
					this.db.Send.Write(this.transaction.Handle);
					this.db.Send.Write(this.handle);
					this.db.Send.Write((int)this.db.Dialect);
					this.db.Send.Write(commandText);
					this.db.Send.WriteBuffer(DescribeInfoItems, DescribeInfoItems.Length);
					this.db.Send.Write(IscCodes.MAX_BUFFER_SIZE);
					this.db.Send.Flush();

					GdsResponse r = this.db.ReadGenericResponse();
					this.fields = this.ParseSqlInfo(r.Data, DescribeInfoItems);

					// Determine the statement type
					this.statementType = this.GetStatementType();

					this.state = StatementState.Prepared;
				}
				catch (IOException)
				{
					this.state = StatementState.Error;
					throw new IscException(IscCodes.isc_net_read_err);
				}
			}
		}
コード例 #24
0
		private void Allocate()
		{
			lock (this.db)
			{
				try
				{
					this.db.Send.Write(IscCodes.op_allocate_statement);
					this.db.Send.Write(this.db.Handle);
					this.db.Send.Flush();

					this.handle = this.db.ReadGenericResponse().ObjectHandle;
					this.allRowsFetched = false;
					this.state = StatementState.Allocated;
					this.statementType = DbStatementType.None;
				}
				catch (IOException)
				{
					this.state = StatementState.Deallocated;
					throw new IscException(IscCodes.isc_net_read_err);
				}
			}
		}
コード例 #25
0
ファイル: GdsStatement.cs プロジェクト: cafee/NETProvider
		public override void Prepare(string commandText)
		{
			// Clear data
			this.ClearAll();

			lock (this.database.SyncObject)
			{
				try
				{
					if (this.state == StatementState.Deallocated)
					{
						// Allocate	statement
						this.SendAllocateToBuffer();
						this.database.Flush();
						this.ProcessAllocateResponce(this.database.ReadGenericResponse());
					}

					this.SendPrepareToBuffer(commandText);
					this.database.Flush();
					this.ProcessPrepareResponse(this.database.ReadGenericResponse());

					// Grab statement type
					this.SendInfoSqlToBuffer(StatementTypeInfoItems, IscCodes.STATEMENT_TYPE_BUFFER_SIZE);
					this.database.Flush(); 
					this.statementType = this.ProcessStatementTypeInfoBuffer(this.ProcessInfoSqlResponse(this.database.ReadGenericResponse()));


					this.state = StatementState.Prepared;
				}
				catch (IOException)
				{
					// if the statement has been already allocated, it's now in error
					if (this.state == StatementState.Allocated)
						this.state = StatementState.Error;
					throw new IscException(IscCodes.isc_net_read_err);
				}
			}
		}
コード例 #26
0
		private void Allocate()
		{
			lock (_db)
			{
				// Clear the status vector
				ClearStatusVector();

				int dbHandle = _db.Handle;
				int stmtHandle = _handle;

				_db.FbClient.isc_dsql_allocate_statement(
					_statusVector,
					ref dbHandle,
					ref stmtHandle);

				_db.ParseStatusVector(_statusVector);

				_handle = stmtHandle;
				_allRowsFetched = false;
				_state = StatementState.Allocated;
				_statementType = DbStatementType.None;
			}
		}
コード例 #27
0
		protected override void Dispose(bool disposing)
		{
			if (!IsDisposed)
			{
				try
				{
					Release();
				}
				catch
				{ }
				finally
				{
					if (disposing)
					{
						Clear();

						_db = null;
						_fields = null;
						_parameters = null;
						_transaction = null;
						_outputParams = null;
						_statusVector = null;
						_allRowsFetched = false;
						_state = StatementState.Deallocated;
						_statementType = DbStatementType.None;
						_recordsAffected = 0;
						_handle = 0;
						FetchSize = 0;
					}

					base.Dispose(disposing);
				}
			}
		}
コード例 #28
0
		protected override void Dispose(bool disposing)
		{
			lock (this)
			{
				if (!IsDisposed)
				{
					try
					{
						// release any unmanaged resources
						Release();
					}
					catch
					{
					}
					finally
					{
						// release any managed resources
						if (disposing)
						{
							Clear();

							_rows = null;
							_outputParams = null;
							_database = null;
							_fields = null;
							_parameters = null;
							_transaction = null;
							_allRowsFetched = false;
							_state = StatementState.Deallocated;
							_statementType = DbStatementType.None;
							_handle = 0;
							_fetchSize = 0;
							RecordsAffected = 0;
						}

						base.Dispose(disposing);
					}
				}
			}
		}
コード例 #29
0
        protected override void Dispose(bool disposing)
        {
            if (!this.IsDisposed)
            {
                try
                {
                    // release any unmanaged resources
                    this.Release();
                }
                catch
                {
                }
                finally
                {
                    // release any managed resources
                    if (disposing)
                    {
                        this.Clear();

                        this.db = null;
                        this.fields = null;
                        this.parameters = null;
                        this.transaction = null;
                        this.outputParams = null;
                        this.statusVector = null;
                        this.allRowsFetched = false;
                        this.state = StatementState.Deallocated;
                        this.statementType = DbStatementType.None;
                        this.recordsAffected = 0;
                        this.handle = 0;
                        this.FetchSize = 0;
                    }

                    base.Dispose(disposing);
                }
            }
        }
コード例 #30
0
        private void Allocate()
        {
            lock (this.db)
            {
                // Clear the status vector
                this.ClearStatusVector();

                int dbHandle = this.db.Handle;
                int stmtHandle = this.handle;

                db.FbClient.isc_dsql_allocate_statement(
                    this.statusVector,
                    ref	dbHandle,
                    ref	stmtHandle);

                this.db.ParseStatusVector(this.statusVector);

                this.handle = stmtHandle;
                this.allRowsFetched = false;
                this.state = StatementState.Allocated;
                this.statementType = DbStatementType.None;
            }
        }
コード例 #31
0
		public override void Prepare(string commandText)
		{
			// Clear data
			ClearAll();

			lock (_db)
			{
				// Clear the status vector
				ClearStatusVector();

				// Allocate the statement if needed
				if (_state == StatementState.Deallocated)
				{
					Allocate();
				}

				// Marshal structures to pointer


				// Setup fields	structure
				_fields = new Descriptor(1);

				IntPtr sqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _fields);
				int trHandle = _transaction.Handle;
				int stmtHandle = _handle;

				byte[] buffer = _db.Charset.GetBytes(commandText);

				_db.FbClient.isc_dsql_prepare(
					_statusVector,
					ref trHandle,
					ref stmtHandle,
					(short)buffer.Length,
					buffer,
					_db.Dialect,
					sqlda);

				// Marshal Pointer
				Descriptor descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda);

				// Free	memory
				XsqldaMarshaler.CleanUpNativeData(ref sqlda);

				// Parse status	vector
				_db.ParseStatusVector(_statusVector);

				// Describe	fields
				_fields = descriptor;

				if (_fields.ActualCount > 0 && _fields.ActualCount != _fields.Count)
				{
					Describe();
				}
				else
				{
					if (_fields.ActualCount == 0)
					{
						_fields = new Descriptor(0);
					}
				}

				// Reset actual	field values
				_fields.ResetValues();

				// Get Statement type
				_statementType = GetStatementType();

				// Update state
				_state = StatementState.Prepared;
			}
		}
コード例 #32
0
		public override void Prepare(string commandText)
		{
			// Clear data
			ClearAll();

			lock (_database.SyncObject)
			{
				try
				{
					if (_state == StatementState.Deallocated)
					{
						// Allocate statement
						SendAllocateToBuffer();
						_database.XdrStream.Flush();
						ProcessAllocateResponce(_database.ReadGenericResponse());
					}

					SendPrepareToBuffer(commandText);
					_database.XdrStream.Flush();
					ProcessPrepareResponse(_database.ReadGenericResponse());

					// Grab statement type
					SendInfoSqlToBuffer(StatementTypeInfoItems, IscCodes.STATEMENT_TYPE_BUFFER_SIZE);
					_database.XdrStream.Flush();
					_statementType = ProcessStatementTypeInfoBuffer(ProcessInfoSqlResponse(_database.ReadGenericResponse()));


					_state = StatementState.Prepared;
				}
				catch (IOException ex)
				{
					// if the statement has been already allocated, it's now in error
					if (_state == StatementState.Allocated)
						_state = StatementState.Error;
					throw IscException.ForErrorCode(IscCodes.isc_net_read_err, ex);
				}
			}
		}