none
Update Command hangs program with OracleDataAdapter RRS feed

  • Question

  • I am trying to do an update on a Oracle Table, I can do SELECTS and INSERTS no problem using the same logic,
    but when I try a simple update as show below it just hangs.  I am using C#.

    ////connection made

    OracleDataAdapter da = new OracleDataAdapter();
    DataSet myDataSet = new DataSet();
    OracleCommandBuilder myOracleCommandBuilder = new OracleCommandBuilder(da);

    OracleCommand cmdSelect = new OracleCommand("Select * table where " +
                                          "Column1 = :p1 and Column2 = p2 ORDER BY Column2", dbConn);

    cmdSelect.Parameters.AddWithValue("p1", value);
    cmdSelect.Parameters.AddWithValue("p2", value);
               
                          
    da.SelectCommand = cmdSelect;
    da.Fill(myDataSet, "TableName");

    /////I return 1 record the one that I want to update
                        
    myDataSet.Tables["TableName"].Rows[0]["Column3"] = 555555;
               
    myOracleCommandBuilder.GetUpdateCommand();
    da.UpdateCommand = myOracleCommandBuilder.GetUpdateCommand();

    da.Update(myDataSet, "TableName");
     
    ////after I run the above command it just hangs.

    da.Dispose();
    cmdSelect.Dispose();
    dbConn.Dispose();

    dbConn.Close();

     

    Thursday, February 3, 2011 8:29 PM

All replies

  • Not sure if it is relevant but in the select statement a FROM is missing and also the second paramter is missing the : (ie. should be Column2 = :p2).
    You can also print out the actual update command text and run it from outside the code and see if this also hangs:

    Console.WriteLine(builder.GetUpdateCommand().CommandText)

    This posting is provided "AS IS" with no warranties.
    Friday, February 4, 2011 8:43 AM
  • Got it corrected I had a IDE open to my database where I had did some updates on the record, but never did a commit and the record was locked.  Was I committed my updates in my IDE it all worked.
    Friday, February 4, 2011 5:21 PM
  • Hi Omega160,

    Welcome to ado.net managed provider.

    I have not the oracle environment, Base your description there is no syntax error  and I hope you could show me more information or the code snippet for the "GetUpdateCommand".  Thanks.

    have a good day.



    David Peng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, February 7, 2011 5:44 AM
    Moderator
  • Hi Omega160,

    Welcome to ado.net managed provider forum.

    Base on your  description there is no syntax error. I hope you could test the update command lonely. I have not the oracle environment,

    so if there is any problem i hope you coud show me more inforamtions such as the code snippet with the myOracleCommandBuilder.GetUpdateCommand function. Thanks!

    Have a good day.



    David Peng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, February 7, 2011 5:49 AM
    Moderator