Re: Problems call DataAdapter.Update and Concurrency
- From: "Steve Lloyd" <steve.remove@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 9 Jan 2007 20:57:46 -0000
Hi Bart,
Yes there is a PK column that I am returning by using the Rowupdated event
for any .Inserted row.
I use a command builder for update command as I want to make use of the
concurrency exception.
I dont know if it is by design for if I have got something wrong, but I can
call .update many times as long I don't change the data (pretty pointless)
as soon as the data gets changed it causes a concurrency violation. In some
ways this is as desired but I wasn't expecting the violation while using the
same Connection as the first update. The only solution I can find is to
repopulate the datatable using the .fill after each update. This works fine
but is costly as the application uses a heavily lagged WAN.
Any thoughts?
Thanks again,
Steve.
"Bart Mermuys" <bmermuys.nospam@xxxxxxxxxxx> wrote in message
news:I_Qoh.281969$WX6.5836931@xxxxxxxxxxxxxxxxxxxxxxxx
Hi,
"Steve Lloyd" <steve.remove@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:OQt6RD%23MHHA.5064@xxxxxxxxxxxxxxxxxxxxxxx
Sorry, I did not call the .Fill correctly, it works if i do this,
however, the question still remains of whether this can be done without
calling the .fill and avoiding another trip to the database.
By default the DataAdapter will call AcceptChanges on each succesfull
updated row, so you should not call it. Although not necesairly the case
here, calling AcceptChanges at the wrong time may even cause a false
"Concurrency Violation".
If i understand it correctly, you only have this problem when you do : add
record, update, modify same record, update and the problem is helped with
calling Fill in between. Do you have an autonumber PK column in the DB
table, if so , which DB are you using and how are you currently building
the insert command (DataAdapter) ?
HTH,
Greetings
Thanks again
Steve
"Steve Lloyd" <steve.remove@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:eWIId59MHHA.992@xxxxxxxxxxxxxxxxxxxxxxx
Hi all,
I wonder if anyone can explain what is happening here?
I have a dataadapter that I am using to correlate the changes in an SQL
Table to a DataTable. I create a new DataRow then call .Update and
acceptchanges, all works fine. The problem I have is when I try to
amend some of the data and the call the Update again. This time I get a
Concurrency error, which is understandable as the data has changed since
I initially created the table but is not the desired outcome and I was
expecting that after accepting changes can calling the .Fill the
concurrency conflict would be resolved.
Is there a way to get the adpater to update the changed rows. I have
tried calling .Fill after the update but this does not seem to help.
Ideally I would like to work on the datatable and not have to repopulate
from the database every time I update a cell/row.
Thanks for any help you can give.
Steve
Here is the code it use:
Try
_tradeAdapter.Update(_detailsTable)
_detailsTable.AcceptChanges()
_tradeAdapter.Fill(_detailsTable)
Catch exTran As DBConcurrencyException
MsgBox("There has been a conflict error on this trade, please refresh
your details and check", MsgBoxStyle.Critical, "Update Conflict")
s.Logging.ApplicationLog.LoggingLevels.ApplicationError)
End Try
.
- Follow-Ups:
- Re: Problems call DataAdapter.Update and Concurrency
- From: RobinS
- Re: Problems call DataAdapter.Update and Concurrency
- From: Bart Mermuys
- Re: Problems call DataAdapter.Update and Concurrency
- References:
- Problems call DataAdapter.Update and Concurrency
- From: Steve Lloyd
- Re: Problems call DataAdapter.Update and Concurrency
- From: Steve Lloyd
- Re: Problems call DataAdapter.Update and Concurrency
- From: Bart Mermuys
- Problems call DataAdapter.Update and Concurrency
- Prev by Date: Re: What's My Password?
- Next by Date: Detach sql files on closing?
- Previous by thread: Re: Problems call DataAdapter.Update and Concurrency
- Next by thread: Re: Problems call DataAdapter.Update and Concurrency
- Index(es):
Relevant Pages
|