PC Review


Reply
Thread Tools Rate Thread

Creating Update commands for DataAdapter dynamically

 
 
RJN
Guest
Posts: n/a
 
      5th Feb 2005
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



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      5th Feb 2005
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


 
Reply With Quote
 
=?Utf-8?B?S2VycnkgTW9vcm1hbg==?=
Guest
Posts: n/a
 
      5th Feb 2005
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


"RJN" wrote:

> 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
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
>

 
Reply With Quote
 
RJN
Guest
Posts: n/a
 
      7th Feb 2005
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataAdapter Commands Charles Microsoft ADO .NET 2 15th Feb 2006 08:36 AM
easy way of creating update commands? cj Microsoft VB .NET 10 19th Dec 2005 06:45 AM
Using DataAdapter.Fill to execute delete, insert and update commands Greg Microsoft ADO .NET 0 28th Apr 2004 09:04 PM
Creating your own INSERT, DELETE and UPDATE commands Mike Lerch Microsoft ADO .NET 5 5th Mar 2004 09:22 PM
Concurrency violation: Problem dynamically creating DataAdapter commands sam Microsoft ADO .NET 2 26th Aug 2003 05:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:48 PM.