By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,143 Members | 1,854 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,143 IT Pros & Developers. It's quick & easy.

Concurrency violation the updatecommand affected 0 records

P: n/a
I have a problem whereby I have a datagrid that is bound to a
However occassionally when I edit the datagrid I get the following message.

Concurrency Violation the update Command affected 0 records.

The message appears to be completely random and If I go back out and into
the form again
it may then work properly.
I looked at the value of the updatecommand in the sqldataadapter and it
always says nothing.

Why does this message occur, is it to do with writing null values back to
the database.
The database gets updated when a cell is clicked on the grid using the
CurrentCellchanged event.
I have attached the relevant code for your assistance.

Thanx in advance.

MyDataGrid.DataSource = MyDataTable

Private Sub MyDataGrid_CurrentCellChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles MyDataGrid.CurrentCellChanged
Dim IntNumRows As Integer = MyDataTable.Rows.Count
IntRowNum = MyDataGrid.CurrentCell.RowNumber

If IntRowNum < IntNumRows Then
Call UpdateTempJobs()
End If

End Sub

Private Sub UpdateTempJobs()
Call DataAccess.UpdateDataSet(MyDataGrid, MySqlDataAdapter,

End Sub

Public Sub UpdateDataSet(ByRef MyDataset As DataSet, ByVal Mysqldataadapter
As SqlDataAdapter, ByVal strTable As String)
Dim objCommandBuilder As New SqlCommandBuilder(Mysqldataadapter)

Mysqldataadapter.Update(MyDataset, strTable)

End Sub
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a

It has probably to do with the updated records in your dataset.
They are not updated when you use by instance autoincrement keys

Than you have after every update to clear the dataset and fill it completly
new especially in a multiuser environment.

I hope this helps?

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.