Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7675533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:59:08+00:00 2026-05-31T16:59:08+00:00

It compiles, it seems to run, but the record is not changed. Here’s my

  • 0

It compiles, it seems to run, but the record is not changed.

Here’s my code:

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();
}

=========
Updated:

So you mean like so, I take it:

try
                {
                    using (var transaction = con.BeginTransaction())
                {
                    cmd.Transaction = transaction;
                    cmd.ExecuteNonQuery();
                    transaction.Commit();
                } 
                }                
                catch (Exception ex)
                {
                    ot.Rollback();
                    throw;
                }
                MessageBox.Show("Apparent success");

===========
Updated yet again (this code works):

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();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:59:10+00:00Added an answer on May 31, 2026 at 4:59 pm

    I note that you really don’t have a way to distinguish whether or not an exception was thrown and the transaction was rolled back or if the transaction succeeded. See, you’re catching the exception, rolling the transaction back, and then still displaying the message box “Apparent success.” because you’re swallowing the exception and falling through. There’s a reason that people scream from the top of rooftops to not swallow exceptions.

    So, I suspect an exception is being thrown, you’re catching it, rolling back, and then getting confused because you fall through and show the message box. This is badly written code, and badly written code introduces bugs like this.

    At a minimum, I’d rethrow the exception if I were you.

    catch (Exception) {
        ot.Rollback();
        throw;
    }
    

    But even better, just wrap the usage of the transaction in a using block

    using(var transaction = con.BeginTransaction()) {
        cmd.Transaction = transaction;
        cmd.ExecuteNonQuery();
        transaction.Commit();
    }
    

    Why is my update statement not updating the table?

    You have a bug in your code. One of these statements

    ot = con.BeginTransaction();
    cmd.Transaction = ot;
    cmd.ExecuteNonQuery();
    ot.Commit();
    

    is throwing an exception but you don’t know it because you’re swallowing all exceptions. Stop swallowing the exceptions, and you’ll find out which of these lines is throwing an exception and why. Then you’ll have more information with which to debug your underlying issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code compiles and it seems to run fine: class Test { private:
I am stuck! this seems really daft but I can not see where I
How come Eclipse compiles my project (automatically) without errors, but when I run Ant
How ASP.NET compiles its assemblies generally confuses me. It seems that I cannot program
When I compile the following code with g++, the object of class A seems
Why won't the following C code compile? It seems like it should just change
This seems like it should be an easy fix, but after searching for hours
OK, I know this question seems pretty easy to answer, or maybe documented, but
I am trying to run a linq query but I need the result as
I want to get code coverage when running unit tests. I run ant coverage

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.