Компилируется, вроде запускается, но запись не меняется.
Вот мой код:
private void UpdateRecord(string ATicketID, string ATicketSource, string AContactsEmail, string AAboutSomeID, string ACategoryID)
{
try
{
con = new OracleConnection(oradb);
con.Open();
String query = "UPDATE ABC.CONCERTTICKETS SET TICKETSOURCE = :p_TICKETSOURCE, ABOUTSOMEID = :p_ABOUTSOMEID, CATEGORYID = :p_CATEGORYID, CONTACTEMAIL = :p_CONTACTEMAIL WHERE TICKETID = :p_TICKETID";
cmd = new OracleCommand(query, con);
cmd.CommandType = CommandType.Text;
OracleParameter p_TICKETID =
new OracleParameter("p_TICKETID", OracleDbType.NVarchar2, ParameterDirection.Input);
p_TICKETID.Size = 20;
p_TICKETID.Value = ATicketID;
cmd.Parameters.Add(p_TICKETID);
OracleParameter p_TICKETSOURCE =
new OracleParameter("p_TICKETSOURCE", OracleDbType.NVarchar2, ParameterDirection.Input);
p_TICKETSOURCE.Size = 20;
p_TICKETSOURCE.Value = ATicketSource;
cmd.Parameters.Add(p_TICKETSOURCE);
OracleParameter p_ABOUTSOMEID =
new OracleParameter("p_ABOUTSOMEID", OracleDbType.Int32, ParameterDirection.Input);
p_ABOUTSOMEID.Value = AAboutSOMEID;
cmd.Parameters.Add(p_ABOUTSOMEID);
OracleParameter p_CATEGORYID =
new OracleParameter("p_CATEGORYID", OracleDbType.Int32, ParameterDirection.Input);
p_CATEGORYID.Value = ACategoryID;
cmd.Parameters.Add(p_CATEGORYID);
OracleParameter p_CONTACTEMAIL =
new OracleParameter("p_CONTACTEMAIL", OracleDbType.NVarchar2, ParameterDirection.Input);
p_CONTACTEMAIL.Size = 100;
p_CONTACTEMAIL.Value = AContactsEmail;
cmd.Parameters.Add(p_CONTACTEMAIL);
try
{
try
{
ot = con.BeginTransaction();
cmd.Transaction = ot;
cmd.ExecuteNonQuery();
ot.Commit();
}
catch (Exception)
{
ot.Rollback();
}
}
catch (OracleException ex)
{
MessageBox.Show(ex.Message);
}
MessageBox.Show("Apparent success");
}
finally
{
con.Close();
con.Dispose();
}
dataGridView1.Refresh();
}
=========
Обновлено:
Так ты имеешь в виду, я так понимаю:
try
{
using (var transaction = con.BeginTransaction())
{
cmd.Transaction = transaction;
cmd.ExecuteNonQuery();
transaction.Commit();
}
}
catch (Exception ex)
{
ot.Rollback();
throw;
}
MessageBox.Show("Apparent success");
===========
Обновлен еще раз (этот код работает):
private void UpdateRecord(string ATicketID, string ATicketSource, string AContactsEmail, string AAboutSomeID, string ACategoryID)
{
try
{
con = new OracleConnection(oradb);
con.Open();
String update = @"UPDATE ABC.CONCERTTICKETS
SET TICKETSOURCE = :p_TICKETSOURCE,
ABOUTSOMEID = :p_ABOUTSOMEID,
CATEGORYID = :p_CATEGORYID,
CONTACTEMAIL = :p_CONTACTEMAIL
WHERE TICKETID = :p_TICKETID";
cmd = new OracleCommand(update, con);
cmd.CommandType = CommandType.Text;
// TICKETSOURCE, ABOUTLLSID, CATEGORYID, CONTACTEMAIL, TICKETID
OracleParameter p_TICKETSOURCE =
new OracleParameter("p_TICKETSOURCE", OracleDbType.NVarchar2, ParameterDirection.Input);
p_TICKETSOURCE.Size = 20;
p_TICKETSOURCE.Value = ATicketSource;
cmd.Parameters.Add(p_TICKETSOURCE);
OracleParameter p_ABOUTSOMEID =
new OracleParameter("p_ABOUTSOMEID", OracleDbType.Int32, ParameterDirection.Input);
p_ABOUTSOMEID.Value = AAboutSOMEID;
cmd.Parameters.Add(p_ABOUTSOMEID);
OracleParameter p_CATEGORYID =
new OracleParameter("p_CATEGORYID", OracleDbType.Int32, ParameterDirection.Input);
p_CATEGORYID.Value = ACategoryID;
cmd.Parameters.Add(p_CATEGORYID);
OracleParameter p_CONTACTEMAIL =
new OracleParameter("p_CONTACTEMAIL", OracleDbType.NVarchar2, ParameterDirection.Input);
p_CONTACTEMAIL.Size = 100;
p_CONTACTEMAIL.Value = AContactsEmail;
cmd.Parameters.Add(p_CONTACTEMAIL);
OracleParameter p_TICKETID =
new OracleParameter("p_TICKETID", OracleDbType.NVarchar2, ParameterDirection.Input);
p_TICKETID.Size = 20;
p_TICKETID.Value = ATicketID;
cmd.Parameters.Add(p_TICKETID);
using (var transaction = con.BeginTransaction())
{
try
{
cmd.Transaction = transaction;
cmd.ExecuteNonQuery();
transaction.Commit();
}
catch (Exception ex)
{
transaction.Rollback();
throw;
}
}
MessageBox.Show("Apparent success");
}
finally
{
con.Close();
con.Dispose();
}
Popul8TheGrid();
}