CommandBuilders have terribly functionality in regard to concurrency, so you
may want to just use an adapter and either use the configuration wizard or
roll your own logic. Bill Vaughn has a great discussion at
www.betav.com ->
Articles -> MSDN weaning developer from the commandbuilder.
As far as your problem... Calling update on cellchanged is probably
overkill. You may want to try .EndCurrentEdit. Nothing about a new row
should cause this inherently, so you may also want to check .GetChanges and
see what those values are.. that will give you some insight in tracking down
the exception. Moreover, since it's concurrency, you know it's something
has perceived to have changed, so the answer will be in looking at the
proposed vs original values.
HTH,
Bill
"Geraldine Hobley" <(E-Mail Removed)> wrote in message
news:48A1623E-F633-41A5-9424-(E-Mail Removed)...
> Hello I'm getting the above mentioned error in my application
>
> I have a datagrid bound to a datasource like so
>
> MyDatagrid.DataSource = Mydataset.Tables(Order) - this all works
fine
>
> However I have another field on the form which is a richtextbox and is
bound to another field in the same datasource
> like so
>
> Me.RtxtDialog.DataBindings.Add("text", MyDataset.Tables.Item("Orders"),
"MyRichTextField") - this field accepts nulls in the database
>
> If you just want to add values to the grid and amend the grid it works
fine however when you add new records to the
> grid and associated values in the rtxDialog text field we get the error
>
> Currency Violation. Update command affect 0 records - when you click on
the next row.
>
> My Datagrid Currentcellchanged event is as follows
>
> Private Sub MyDataGrid_CurrentCellChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyDataGrid.CurrentCellChanged
> Dim IntRowNum As Integer = MyDataGrid.CurrentCell.RowNumber
> Dim MyGridfunctions As New ProjectNameSpace.Gridfunctions
> Dim IntNumRows As Integer =
MyGridfunctions.NumRowsInGrid(MyDataGrid)
> Dim MyDataAccess As New DataAccess.DataAccess
>
> If IntRowNum <= IntNumRows Then
> Call Updatedialogue(StrTypeOfdialogue)
> ElseIf IntRowNum = IntNumRows Then 'adding a new row
> Call Updatedialogue(StrTypeOfdialogue)
> End If
>
> End Sub
>
> Private Sub Updatedialogue(ByVal strtable As String)
> Dim MyDataAccess As New DataAccess.DataAccess
>
> DirectCast(BindingContext(mydataset.Tables.Item(Orders)),
CurrencyManager).EndCurrentEdit()
> If MyDataSet.HasChanges Then
> Call MyDataAccess.UpdateDataSet(MyDataset, MysqldataAdapter,
Orders)
>
> End If
>
> End Sub
>
> 'THIS IS WHERE THE ERROR OCCURS
>
> Public Sub UpdateDataSet(ByRef MyDataset As DataSet, ByVal
Mysqldataadapter As SqlDataAdapter, ByVal strTable As String)
>
> Dim objCommandBuilder As New SqlCommandBuilder(Mysqldataadapter)
> Try
> Mysqldataadapter.Update(MyDataset, strTable)
> Catch e As Exception
> MsgBox(e.Message)
> End Try
> End Sub
>
>
> Any ideas how to avoid this error, what I'm doing wrong or at least how I
can see the actual update command that is been performed, including the
values of the parameters. I've tried
myadapter.updatecommand.parameters.item(0). etc and is says that the
parameters have a value of nothing on both the successfull and non
successfull updates.
>
> The error only occurs when adding a new row and then adding something in
the non-datagrid field rtxtDialog and then clicking on the next row in the
grid.
>
> Any help would be greatly appreciated
>
> Geri
>