> puts this "getChanges" dataset into DataAdapter with the proper update,
insert and delete commands and calls it's Update method.
Unfortunately, I'm not in a position where I can test this at the
moment, so I have a couple questions regarding the DataAdapter...
As far as I know, creating the DataAdapter object requires a SELECT
statement. For the purpose of using this DataAdapter to hold INSERT,
UPDATE, and DELETE statements, does that SELECT statement have to
exactly match the SELECT statement that produced the DataSet being
passed to this function? Or is it really arbitrary at that point in the
process?
For the INSERT, UPDATE, and DELETE statements, am I right in
understanding that I just write one generic one for a row in that table
with parameters and the object will know to iterate through the changed
records and plug them in as necessary? For example, suppose the
following table:
Columns for table Users:
UID (integer, PK, auto-increment)
Name (varchar(30), nullable)
Records:
1 Robert
2 Micheal
3 Jeff
I put the whole table into a DataSet and display it on a DataGrid. In
the grid, I correct the spelling of the second record. Then I raise
some event (button click, for example) that saves the .GetChanges of the
DataGrid's DataSource to a new DataSet and sends that DataSet to a web
service function.
That function creates a DataAdapter with an arbitrary SELECT statement,
but includes an UpdateCommand object as such:
OleDbCommand uCmd = new OleDbCommand("UPDATE Users SET Name=? WHERE
UID=?", dbConnection);
[define parameter types here, blah blah blah, set the DataAdapter's
UpdateCommand to this command]
Then I just call Update on that DataAdapter and pass it the DataSet and
it will update any changes records automatically?
What if the PK is changed? How will it then know what to update?
Regards,
David P. Donahue
dd******@ccs.neu.edu http://www.cyber0ne.com