I am trying to update an Access database.
I am attempting to do the update via a Dataview
The record to be edited is found and the Dataview data
is edited OK. My problem occurs when I try to save this to the database.
I don't get an error but the dataview has the updated data and this data
is not saved to the underlying database as I require.
'A Dataset dsBirds already exists and is populated
If Action = "Edit" Then
'Find Record in Dataview
Dim SortBy As String
SortBy = "yr, ringno"
Dim pRow As DataRowView
Dim dv1 As DataView
dv1 = New DataView
Dim oBird1(1) As Object
oBird1(0) = CLng(txtYear.Text)
oBird1(1) = txtRingNo.Text
With dv1
.Table = dsBirds.Tables("Bird")
.AllowDelete = False
.AllowEdit = True
.AllowNew = False
.Sort = SortBy
End With
Dim i As Long
i = dv1.Find(oBird1)
dv1(i).Item("name") = "Tweety"
dv1(i).Item("sex") = "Hen"
' The problem is around here...
'send row through to dataadaptor to update table
'the sdaBirds is the original dataadaptor
me.sdaBirds.Update("dsBirds", "Bird")
dv1.Table.AcceptChanges()
End If
End Function
I am attempting to do the update via a Dataview
The record to be edited is found and the Dataview data
is edited OK. My problem occurs when I try to save this to the database.
I don't get an error but the dataview has the updated data and this data
is not saved to the underlying database as I require.
'A Dataset dsBirds already exists and is populated
If Action = "Edit" Then
'Find Record in Dataview
Dim SortBy As String
SortBy = "yr, ringno"
Dim pRow As DataRowView
Dim dv1 As DataView
dv1 = New DataView
Dim oBird1(1) As Object
oBird1(0) = CLng(txtYear.Text)
oBird1(1) = txtRingNo.Text
With dv1
.Table = dsBirds.Tables("Bird")
.AllowDelete = False
.AllowEdit = True
.AllowNew = False
.Sort = SortBy
End With
Dim i As Long
i = dv1.Find(oBird1)
dv1(i).Item("name") = "Tweety"
dv1(i).Item("sex") = "Hen"
' The problem is around here...
'send row through to dataadaptor to update table
'the sdaBirds is the original dataadaptor
me.sdaBirds.Update("dsBirds", "Bird")
dv1.Table.AcceptChanges()
End If
End Function