Re: DataGridView bound to TypedDataSet - Update causes Concurrency Violation

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



From Brian Noyes' data binding book:

If you have made any changes to the rows in your data set and call
AcceptChanges, the original values for all modified rows will be
replaced with the current values, and the state of all rows will
be set to Unchanged.

You should be aware when using these methods, however, that you
generally want to avoid using them if the data in the data set
will be used to update a database through a data adapter.
The data adapter figures out which commands to execute (update,
insert or delete) for which rows based on their row state.

Rows with a row state of Unchanged don't get any command
executed against them when performing an update.

Instead of calling AcceptChanges, why don't you update the
dataset through the data adapter? I think this would write
the data to the underlying database, and update your dataset
at the same time.

That's my two cents' worth. Hope it helps.

Robin S.
---------------------------------

<rmgalante@xxxxxxxxxxxx> wrote in message
news:1164836106.630426.154370@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have a Windows Forms Application with a DataGridView which is bound
to a typed DataSet. For reasons specific to the application, I add a
record to the database table when a button is clicked on the form. This
button creates a record with default values so the user only has to
change what they do want as defaults.

During the add logic, I programmatically add a row to the typed DataSet
view with the AddMyTableNameRow method. This works. I call the row's
AcceptChanges(). Then I attempt to refresh the DataGridView with the
Refresh() command.

The problem I have is, when I edit one of the rows in the DataGridView
and call the update command, I get the Concurrency violation. The
UpdateCommand affected 0 of the expected 1 rows.

However, if I Fill the adapter after I add a record, then edit a row,
and call the update command, I do not get the Concurrency violation.

This leads me to believe that the grid is not synchronized with the
underlying table after I add a row, and the concurrency violation is
one of those error messages that means "alot of different things could
have caused the problem."

So how do I add a row to the underlying dataset, and make sure the
datagridview is synchronized with the underlying dataset, so that
subsequent updates do not fail?

Thanks.



.



Relevant Pages

  • Re: Migrating me from linux/bsd to zOS
    ... My "application" for the COPY command was in a sequence ALLOCATE, COPY, ... to tidy up a data set which had had a lot of activity: ... REQUIRED - 'DSNAME1' AND 'DSNAME2' ... THE FORMAT COMMAND PROVIDES COMPREHENSIVE FORMATTING ...
    (bit.listserv.ibm-main)
  • Re: ISMF SAVE and E37 ABEND
    ... I was just talking about ISMF. ... The SAVE command writes the data set list to either the ISPF list data set ... Once SAVE'd the user then enters LIST if they used the SAVE command without ... Type SAVE and a list name and the list is saved as a member of the currently ...
    (bit.listserv.ibm-main)
  • Re: ISMF SAVE and E37 ABEND
    ... and ISMF. ... The SAVE command writes the data set list to either the ISPF list data set ... Once SAVE'd the user then enters LIST if they used the SAVE command without ... Type SAVE and a list name and the list is saved as a member of the currently ...
    (bit.listserv.ibm-main)
  • Re: DFHSM QUESTION - REFRESH STC
    ... Space Management Is Controlled ... DFSMShsm allows space management by data set command for any of a group ... MIGRATION specifies that DFSMShsm will do space management automatically ...
    (bit.listserv.ibm-main)
  • Re: UpdateCommand wont update
    ... > AcceptChanges). ... > When you do a DataAdapter.Update with a CommandBuilder generated command ... >> Public Sub UpdateDatabase(ByVal dts As DataSet, ... >> Dim adpNew As New OleDb.OleDbDataAdapter ...
    (microsoft.public.dotnet.framework.adonet)