I am looking into finding out why an update using the Update method for the OracleDataAdapter does not work as expected.
BTW I have used the same code modified for SQL Server and found it to work as expected i.e. throw the DBConcurrencyException exception.
Steps taken to test.
a) Basically I fill the datatable.
b) Manually update record 5 and commit the changes using TOAD
c) Programmatically update the same record within the console application
d) Expect the objAdapter.Update(dtPerson.Select(null, null, DataViewRowState.ModifiedCurrent)); to return a 0. In this case it returns a 1.
e) Throw a DBConcurrencyException exception. Exception not thrown.
d) A check of the database shows that the values in record 5 are NOT updated.
I have added all the necessary adapter commands - Insert, Delete, Update and Select.
Any help will be very good.
Thanks
Daryl
Please see code extract below for details.
Code: Select all
// Devart Oracle Client
OracleConnection objConn = new OracleConnection("Data Source=DEVDB; User ID=SA; Password=password");
OracleDataAdapter objAdapter = new OracleDataAdapter();
// Update Command
OracleCommand objUpdateCmd = new OracleCommand();
objUpdateCmd.Connection = objConn;
objUpdateCmd.CommandText = "pkge_family.update_person";
objUpdateCmd.CommandType = CommandType.StoredProcedure;
objUpdateCmd.Parameters.Add("p_id", OracleDbType.Integer, 4, "ID");
objUpdateCmd.Parameters.Add("p_name", OracleDbType.VarChar, 40, "NAME");
objUpdateCmd.Parameters.Add("p_age", OracleDbType.Integer, 4, "AGE");
objUpdateCmd.Parameters.Add("p_lastupdated", OracleDbType.TimeStamp, 8, "LASTUPDATED");
objUpdateCmd.Parameters.Add("p_NewLastUpdated", OracleDbType.TimeStamp, 8, ParameterDirection.Output, false, 0, 0, "LASTUPDATED", DataRowVersion.Current, null);
objAdapter.UpdateCommand = objUpdateCmd;
// Get all person records
DataTable dtPerson = new DataTable();
objAdapter.Fill(dtPerson);
// Perform a manual to record with ID of 5
// Programmatic Update
DataRow[] personRow = dtPerson.Select("ID = 5");
personRow[0]["Age"] = 50;
personRow[0]["Name"] = "Jimmey";
int x1 = objAdapter.Update(dtPerson.Select(null, null, DataViewRowState.ModifiedCurrent));
catch (DBConcurrencyException exDBC)
{
// No exception is thrown x1 = 1 but note that the database contents are not changed
// from the manual updated values.
}