public override void Execute() { if (_state == StatementState.Deallocated) { throw new InvalidOperationException("Statement is not correctly created."); } // Clear data Clear(); lock (_database.SyncObject) { try { RecordsAffected = -1; SendExecuteToBuffer(); _database.XdrStream.Flush(); if (_statementType == DbStatementType.StoredProcedure) { ProcessStoredProcedureExecuteResponse(_database.ReadSqlResponse()); } GenericResponse executeResponse = _database.ReadGenericResponse(); ProcessExecuteResponse(executeResponse); // Updated number of records affected by the statement execution if (ReturnRecordsAffected && (StatementType == DbStatementType.Insert || StatementType == DbStatementType.Delete || StatementType == DbStatementType.Update || StatementType == DbStatementType.StoredProcedure)) { SendInfoSqlToBuffer(RowsAffectedInfoItems, IscCodes.ROWS_AFFECTED_BUFFER_SIZE); _database.XdrStream.Flush(); RecordsAffected = ProcessRecordsAffectedBuffer(ProcessInfoSqlResponse(_database.ReadGenericResponse())); } _state = StatementState.Executed; } catch (IOException ex) { _state = StatementState.Error; throw IscException.ForErrorCode(IscCodes.isc_net_read_err, ex); } } }