private void Prepare(bool returnsSet) { LogCommand(); FbConnectionInternal innerConn = _connection.InnerConnection; // Check if we have a valid transaction if (_transaction == null) { if (innerConn.IsEnlisted) { _transaction = innerConn.ActiveTransaction; } else { _implicitTransaction = true; _transaction = new FbTransaction(_connection, _connection.ConnectionOptions.IsolationLevel); _transaction.BeginTransaction(); // Update Statement transaction if (_statement != null) { _statement.Transaction = _transaction.Transaction; } } } // Check if we have a valid statement handle if (_statement == null) { _statement = innerConn.Database.CreateStatement(_transaction.Transaction); } // Prepare the statement if needed if (!_statement.IsPrepared) { // Close the inner DataReader if needed DisposeReader(); // Reformat the SQL statement if needed string sql = _commandText; if (_commandType == CommandType.StoredProcedure) { sql = BuildStoredProcedureSql(sql, returnsSet); } try { // Try to prepare the command _statement.Prepare(ParseNamedParameters(sql)); } catch { // Release the statement and rethrow the exception _statement.Release(); _statement = null; throw; } // Add this command to the active command list innerConn.AddPreparedCommand(this); } else { // Close statement for subsequently executions Close(); } }
private void Prepare(bool returnsSet) { #if (DEBUG) System.Diagnostics.Debug.WriteLine(string.Format("Command:\n{0}", commandText)); if (this.parameters != null) { foreach (FbParameter item in this.parameters) { System.Diagnostics.Debug.WriteLine(string.Format("Name:{0} \t Type:{1} \t Value:{2}", item.InternalParameterName, item.FbDbType, item.InternalValue)); } } #endif FbConnectionInternal innerConn = this.connection.InnerConnection; // Check if we have a valid transaction if (this.transaction == null) { if (innerConn.IsEnlisted) { this.transaction = innerConn.ActiveTransaction; } else { this.implicitTransaction = true; this.transaction = new FbTransaction(this.connection, this.connection.ConnectionOptions.IsolationLevel); this.transaction.BeginTransaction(); // Update Statement transaction if (this.statement != null) { this.statement.Transaction = this.transaction.Transaction; } } } // Check if we have a valid statement handle if (this.statement == null) { this.statement = innerConn.Database.CreateStatement(this.transaction.Transaction); } // Prepare the statement if needed if (!this.statement.IsPrepared) { // Close the inner DataReader if needed this.CloseReader(); // Reformat the SQL statement if needed string sql = this.commandText; if (this.commandType == CommandType.StoredProcedure) { sql = this.BuildStoredProcedureSql(sql, returnsSet); } try { // Try to prepare the command this.statement.Prepare(this.ParseNamedParameters(sql)); } catch { // Release the statement and rethrow the exception this.statement.Release(); this.statement = null; throw; } // Add this command to the active command list innerConn.AddPreparedCommand(this); } else { // Close statement for subsequently executions this.Close(); } }