Hello,
I have a problem whereby I have a datagrid that is bound to a
dataTable.
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.
Geri
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()
DirectCast(BindingContext(MyDataTable),
CurrencyManager).EndCurrentEdit()
Call DataAccess.UpdateDataSet(MyDataGrid, MySqlDataAdapter,
MyDataTAble)
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