1

I have tried everything, googled for days, but nothing I found helped me.

I have Oracle 9i db, table TIME_UNITS that have several fields - for my purposes I use only 3, defined as: CODE - VARCHAR2(6), FOR_IN - VARCHAR2(1), FOR_OUT - VARCHAR2(1). My code is:

string strConString = "provider=MSDAORA;DSN=myDSN;user id=myUser;password=myPassword";
string strQuery = "UPDATE TIME_UNITS SET FOR_IN='Y', FOR_OUT='Y' WHERE CODE='202003'";

using (OleDbConnection oleDbConn = new OleDbConnection(strConString ))
using (OleDbCommand cmd = new OleDbCommand(strQuery, oleDbConn))
{
    oleDbConn.Open();

    cmd.Transaction = oleDbConn.BeginTransaction(); 
    int rows = cmd.ExecuteNonQuery();
    cmd.Transaction.Commit();

    oleDbConn.Close();
}

ExecuteNonQuery returns one row, but when I look into db using sqldeveloper nothing is changed. The same statement works perfectly in sqldeveloper using the same credentials. I've tried with and without transaction begin-commit, but still no change in database. What am I doing wrong?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Alexp
  • 11
  • 3
  • 1
    Maybe SQL Developer has pending commits? Try restarting SQL Developer. Happened here for me several times, too. – Uwe Keim Mar 05 '20 at 11:21
  • No, sqldeveloper works fine, if I do it from sqldeveloper it changes fields FOR_IN and FOR_OUT into 'Y' no problem. But if I do it from code, no error, ExecuteNonQuery returns 1, but nothing is changed in db (refreshed, restarted developer, but still no change) – Alexp Mar 05 '20 at 11:25
  • I wonder that you don't get any error, the connection string is wrong. It must be `Data Source=myDSN` instead of `DSN=myDSN` – Wernfried Domscheit Mar 05 '20 at 12:03
  • Should not be, the very same connection string works perfectly when I use SELECT. It's UPDATE that is somehow failing, not committing. And credentials are OK, got permission to write. – Alexp Mar 05 '20 at 12:16

0 Answers0