var oraConnectionString = new OracleConnectionStringBuilder(_connectionString);
using (var oraConnection = new OracleConnection(oraConnectionString.ConnectionString))
{
oraConnection.Open();
try
{
using (var command = new OracleCommand(sqlText, oraConnection))
{
command.Parameters.Clear();
command.BindByName = true;
command.Parameters.Add("node", _currentNode);
command.Parameters.Add("carrierId", CarrierId);
command.Connection.BeginTransaction();
command.ExecuteNonQuery();
command.CommandText = UtilityMethods.LoadTemplate("Resources/CreateCarrier.sql", "Carriers");
command.Parameters.Clear();
command.Parameters.Add("carrierName", CarrierName);
command.Parameters.Add("line1", Line1);
command.Parameters.Add("line2", Line2);
command.Parameters.Add("line3", Line3);
command.Parameters.Add("line4", Line4);
command.ExecuteNonQuery();
command.CommandText = UtilityMethods.LoadTemplate("Resources/GetCarrierId.sql", "Carriers");
CarrierId = Convert.ToString(command.ExecuteScalar());
if (CarrierId == null)
{
//TODO
}
command.Parameters.Clear();
command.CommandText = command.CommandText = UtilityMethods.LoadTemplate("Resources/AddCarrierToNode.sql", "Carriers");
command.Parameters.Add("node", _currentNode);
command.Parameters.Add("rank", Convert.ToInt32(Rank));
command.Parameters.Add("carrierId", Convert.ToInt32(CarrierId));
command.ExecuteNonQuery();
command.Transaction.Commit();
}
}
For some reason CarrierId is returning null. The only thing that I can think of is that the changes from the previous sql commands have not been committed. Can anyone please tell me if you need to commit between each execution?