I am kinda a young programmer so bear with me
I am having difficulties updating rows in the DB when working with a dynamic data adapter update command.
This means that not only I specify the changed value, I also specify the columns where the change is done.
I am implementing a RollBack function, I have a table containing changes done in different tables.
That table includes the fields:
TABLE_NAME - name of the table where the change was done
NEW_VALUE - The value the field changed to.
OLD_VALUE - The previous value the field had
FIELD_NAME - The field name where the change was done
some other irrelevant fields that contain the PK's field name and value.
So basically when I try to update it would look like that:
foreach (DataRow drChangedRow in dtChangedTbl.Rows)
drTableToUpdate[drChangedRow[FIELD_NAME]] = drChangedRow[OLD_VALUE];
(Sorry for the detailed desc just don't want misunderstandings)
Now when I try to update the OracleDataAdapter, I need to specify an UpdateCommand to it.
What I thought of is:
OracleCommand cmdUpdate =
new OracleCommand("UPDATE strTableName" +
"SET :FieldName = :FieldValue" +
"WHERE :PKFieldName = :PKFieldValue");
cmdUpdate.Parameters.Add("PKFieldName ", OracleDbType.VarChar2);
It doesn't work...
My only guess is needing to connect somehow the parameter name with actually how I insert the info.
Any help would be appreciated.