Transaction error

  • Thread starter João Santa Bárbara
  • Start date
J

João Santa Bárbara

Hi all,
i have a problem with a transaction.i will tray to explain my problem.
i have a Dataset that i have fill using 2 DataAdapter with a simple query
( all tables with an autonumber).

i have made code for the dataadapter rowupdate to get the @@identity of my
table.
everything works fine.

now is the problem,
i have made a transaction to made this works,
when i do the endcurrent edit of my CurrencyManager, i want to submit the
row to the DataBase.
i have submited the first table and works fine
when i try to submit the second table it throws an exception.
after that every thing is ok

but when i press again the save button
when i´m going to submit the first table again it throws an cocurrency
violation, and the row state
of the row that i´m try to submit have changed the rowstate from Added to
Modified. anyone knows why ??

thsk
JSB

plsea see the code below


so i have made some thing like this

'update Function
dim cmd as SQlClient.CommandBulider ( DataAdapter)
dim cmd1 as SQlClient.CommandBulider ( DataAdapter2)
try

BD.Open
trans = bd.BeginTransaction

DataAdapter.update ( Ds,Table)
' some code that mades a error
' bla bla bla
' in this peace of code ocurs an Error that throws an Exception
DataAdapter2.update ( Ds,Table2)

trans.comit
catch
trans.rollback
finally
bd.close
end try
 
G

Guest

Sounds like you have two separate commands wrapped inside of a single transaction where the second command is dependent upon the first for Identity value/s. What is happening is when you execute the first command (by pressing the save button) the database is being updated but your client is not. That's what's causing the concurrency error. You need to update the data your client is holding (in the second command) before trying to update that. If you're trying to execute the first command again (without updating the data) you again see the error for the same reason
Make sure that you don't commit/rollback changes until both commands have executed successfully/or not. Otherwise you may not get the desired results by attempting to commit changes after the transaction has been commited (it only takes one commit)

To see what the difference is between the database and your client/s, call GetChanges on both of your datasets

This posting is provided "AS IS" with no warranties, and confers no rights

----- João Santa Bárbara wrote: ----

Hi all
i have a problem with a transaction.i will tray to explain my problem
i have a Dataset that i have fill using 2 DataAdapter with a simple quer
( all tables with an autonumber)

i have made code for the dataadapter rowupdate to get the @@identity of m
table
everything works fine

now is the problem
i have made a transaction to made this works
when i do the endcurrent edit of my CurrencyManager, i want to submit th
row to the DataBase
i have submited the first table and works fin
when i try to submit the second table it throws an exception
after that every thing is o

but when i press again the save butto
when i´m going to submit the first table again it throws an cocurrenc
violation, and the row stat
of the row that i´m try to submit have changed the rowstate from Added t
Modified. anyone knows why ?

ths
JS

plsea see the code belo


so i have made some thing like thi

'update Functio
dim cmd as SQlClient.CommandBulider ( DataAdapter
dim cmd1 as SQlClient.CommandBulider ( DataAdapter2
tr

BD.Ope
trans = bd.BeginTransactio

DataAdapter.update ( Ds,Table
' some code that mades a erro
' bla bla bl
' in this peace of code ocurs an Error that throws an Exceptio
DataAdapter2.update ( Ds,Table2

trans.comi
catc
trans.rollbac
finall
bd.clos
end tr
 

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