K
Katty
When deleting a row and then updating the dataset I use this code:
Function GetRow(ByVal BindingContext As BindingContext, ByVal _
Dataset As DataSet, ByVal Table As String) As DataRow
Dim bm As BindingManagerBase
Dim drv As DataRowView
bm = BindingContext(Dataset, Table)
drv = CType(bm.Current, DataRowView)
GetRow = drv.Row
End Function
' Deleting:
dr = GetRow(BindingContext, Dataset, "Table")
dr.BeginEdit()
dr.Delete()
' Updating:
Me.DataAdapter.Update(Dataset)
The code works great. However, what I need is to delete a row from
a mdi parent dataset, and then update the data source. I'm using this:
dr = GetRow(BindingContext, CType(Me.ActiveForm, Parent).Dataset, "Table")
dr.BeginEdit()
dr.Delete()
CType(Me.ActiveForm, Parent).DataAdapter.Update(CType(Me.ActiveForm,
Parent).Dataset)
Then I get the error:
System.Data.DBConcurrencyException: "Concurrency violation: the
DeleteCommand
affected 0 records." exception when deleting a row/record from a dataset.
Help, PLEASE
Function GetRow(ByVal BindingContext As BindingContext, ByVal _
Dataset As DataSet, ByVal Table As String) As DataRow
Dim bm As BindingManagerBase
Dim drv As DataRowView
bm = BindingContext(Dataset, Table)
drv = CType(bm.Current, DataRowView)
GetRow = drv.Row
End Function
' Deleting:
dr = GetRow(BindingContext, Dataset, "Table")
dr.BeginEdit()
dr.Delete()
' Updating:
Me.DataAdapter.Update(Dataset)
The code works great. However, what I need is to delete a row from
a mdi parent dataset, and then update the data source. I'm using this:
dr = GetRow(BindingContext, CType(Me.ActiveForm, Parent).Dataset, "Table")
dr.BeginEdit()
dr.Delete()
CType(Me.ActiveForm, Parent).DataAdapter.Update(CType(Me.ActiveForm,
Parent).Dataset)
Then I get the error:
System.Data.DBConcurrencyException: "Concurrency violation: the
DeleteCommand
affected 0 records." exception when deleting a row/record from a dataset.
Help, PLEASE