CommandBuilder ConflictOption usage

  • Thread starter Thread starter Darren
  • Start date Start date
D

Darren

I'd like to use the command builder to create update queries but my database schema uses datetime
columns for the last time modified instead of a timestamp. Unfortunately ConflictOption.CompareRowVersion
seems to only work if a timestamp exists.

The update command seems to be rewritten by the dataadapter update method. I added an event handler for
the RowUpdating event and the update command is different inside the handler. I'm guessing the update
command is created dynamically for each row.

Looks like I'll need to fire up reflector.
 
Hi Darren,

The CommandBuilder is used in generally ways to generate the insert, update
and delete commands. It registers itself as a listener for RowUpdating
events whenever you set the DataAdapter property. As far as I know, it is
no use to handle the RowUpdating event if you need to change the update
command. The event handler registered by CommandBuilder will change it back
right before the command is executed.

In this case, I think we have 2 options here.

1. To use ConflictOption.CompareAllSearchableValues to check on all the
fields.
2. Write our own stored procedure to do the insert/update/delete instead of
using CommandBuilder.

Kevin Yu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
I was able to modify the update command in the RowUpdating handler. It seems to
work but it's a bit clumsy. At least it's better than resorting to stored procedures.
 
Hi Darren,

Oh, yes, it is a little clumsy. But the CommandBuilder is designed to
accept timestamp as the identifier of row version. I'm sorry for the
inconvenience.

Kevin Yu
Microsoft Online Community Support
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top