Updating database rows usign OracleClient - .NET Framework 1.1

J

JAW

I have the following code......

private ReturnValue ProcessNonQuery (string sql)
{
ReturnValue status = ReturnValue.SUCCESS;

OracleTransaction myTrans = con.BeginTransaction ();

OracleCommand myUpdate = new OracleCommand(sql, con, myTrans);
myUpdate.CommandType = CommandType.Text;

try
{
int numRows = 0;
numRows = myUpdate.ExecuteNonQuery ();
}

catch
{
myTrans.Rollback ();
return ReturnValue.DB_EXECUTENONQUERY;
}

myTrans.Commit();

return status;
}


The connection is already made and the connection object (con) is valid. When I ussue a simple update statement the db
row is nerver updated. If I take this same statement (sql) and paste it into SQL worksheet using the same
username/password and run it, it works just fine. I have a simple connection statement of :

User ID = <user>; Password = <pwd>;Data Source = <dsn>.

The database server is Oracel 9i (9.2.x) and I have the appropiate 9i client on my development workstation.


Any ideas as to why the update is not occuring ?

Thanks !
Jerry
 
D

David Browne

JAW said:
I have the following code......

private ReturnValue ProcessNonQuery (string sql)
{
ReturnValue status = ReturnValue.SUCCESS;

OracleTransaction myTrans = con.BeginTransaction ();

OracleCommand myUpdate = new OracleCommand(sql, con, myTrans);
myUpdate.CommandType = CommandType.Text;

try
{
int numRows = 0;
numRows = myUpdate.ExecuteNonQuery ();
}

catch
{
myTrans.Rollback ();
return ReturnValue.DB_EXECUTENONQUERY;
}

myTrans.Commit();

return status;
}


The connection is already made and the connection object (con) is valid.
When I ussue a simple update statement the db row is nerver updated. If I
take this same statement (sql) and paste it into SQL worksheet using the
same username/password and run it, it works just fine. I have a simple
connection statement of :

User ID = <user>; Password = <pwd>;Data Source = <dsn>.

The database server is Oracel 9i (9.2.x) and I have the appropiate 9i
client on my development workstation.


Any ideas as to why the update is not occuring ?

You are eating exceptions. Don't do that. It's a deeply wrong thing to do.

catch
{
myTrans.Rollback ();
return ReturnValue.DB_EXECUTENONQUERY;
}

Should be

catch
{
myTrans.Rollback ();
throw;
}

David
 
J

JAW

David;

Thanks for the pointer, but I do not believe it solves my origianl issue. Any suggestions as to the solving of the
original issue ?
 
D

David Browne

JAW said:
David;

Thanks for the pointer, but I do not believe it solves my origianl issue.
Any suggestions as to the solving of the original issue ?

If the update is not occuring then you should get an exception. Either that
or your update statement matches no rows.

David
 
J

JAW

Thaks for your time David.

J

David said:
If the update is not occuring then you should get an exception. Either that
or your update statement matches no rows.

David
 
Top