473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Creating Update commands for DataAdapter dynamically

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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #1
3 1783
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
Nov 21 '05 #2
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!

Nov 21 '05 #3
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: CaptRR | last post by:
I think this is the right group to post to, so here goes. My problem is this, I cannot update the datarow to save my life. Been on this for 2 days now, and still am no closer to figuring it out...
10
by: cj | last post by:
I have lots of tables to copy from one server to another. The new tables have been created to match the old ones. I practiced with one table. I created the select command (select * from tableA)...
0
by: lianaent | last post by:
Hi All, I'm brand new to asp.net 2.0, and have a simple task of just creating a quick and dirty data entry form with SQL Server 2005 on the back end. I added a gridview to my form, and I can...
13
by: Terry Olsen | last post by:
I'm using OleDb to connect with an Access Database. I have anywhere from 10 to over 100 records that I need to either INSERT if the PK doesn't exist or UPDATE if the PK does exist, all in a single...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.