Re: Problems call DataAdapter.Update and Concurrency

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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






.



Relevant Pages

  • Re: Dataset Update / AcceptChange / RejectChanges
    ... So, if I perform an update, which implicitly calls AcceptChanges and then ... My changes are already being persisted to the database via the .Update ... What is the advantage of using the GetChanges command? ... Should I be calling ds.AcceptChanges right after the call to ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Inserting a row - not working
    ... You shouldn't call AcceptChanges on any instance - if you do, you are practially saying that there is no need to update anything in database ... You have to persist changes in dataset to database by calling adapter.Update on that table. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Updating a dataadapter
    ... Rather than calling DataSet11.GetChanges, just call the Dataset. ... However, when I add another record and update the dataadapter again, ... the first record gets added a second time. ...
    (microsoft.public.dotnet.languages.vb)
  • Updating database using dataset without dataadapter?
    ... Is there a way to update the changed dataset without calling ... object and dataadapter is hidden, how do i update the changed rows ... back to database? ...
    (microsoft.public.dotnet.framework.adonet)
  • RE: function doesnt return value - SOMETIMES!
    ... It seems the calling stack has some issues. ... If not, I suggest that you create a new database, and import the ... |> thing I can see is that you are declaring 3 of your numerical values as ... |> when it does work correctly that would be because this data type is ...
    (microsoft.public.access.modulesdaovba)