Creating Update commands for DataAdapter dynamically

R

RJN

Hi

I'm using the Dataadapter and Dataset to do an insert/update/delete into
tables. The dataset has multiple tables in it. I want to write my own
Update/Insert commands for the Dataadapter for each of the tables and
not use the ones created by SqlCommandBuilder. The Update/Delete
commands created by Command builder do not create where clause based on
the primary key but the where cluase created will be based on all the
columns. This creates problems of "Concurrency Violation" if the record
gets modified by any other transaction.

Is there a way to write a generic GetUpdateCommand by passing the
datatable and the Primarykeycolumns as objects(Type Object) and then use
reflection to Get the actual types and then based on the columns in the
table passed create the update command?

Regards

Rjn
 
C

Cor Ligthert

RJN,

Do you have any idea why Microsoft did not built what you ask in the
commandbuilder when it is so simple that it can be given as answer in a
newsgroup?

Just my thought,

Cor
 
G

Guest

RJN,

How are you planning on handling concurrency violations?

You will either need to use a Where clause with all the columns, like the
command builder is now doing, or a timestamp column.

Or do you just need for the latest update to always win? It seems like that
would be a fairly rare choice to be able to make.

Kerry Moorman
 
R

RJN

Hi

Thanks both for your reply. My intention is not to use the
Updatecommands created by SqlCommand builder. My requirement is to
update a table based on a PK column. The update commands created by
command builder will not create this. I can write my own update commands
for all the tables we're using. I was only thinking if there could be a
generic way of doing this.

Regards

Rjn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top