M
marshallarts
Hello,
I have a datagrid (grdShots) on a form, and a button to allow the user
to delete records from the dataset underlying the grid. My code
appears to work, because the row disappears from the datagrid. But the
delete is not being updated back to the data source, because if I exit
the app then start it again, the record reappears in the grid - it has
not been deleted. Code for deleting the row is as follows. Column 0
in the grid is the ID of the record, which is its primary key.
Dim iImage as Long
Dim dr as DataRow
iImage = grdShots.Item(grdShots.CurrentRowIndex, 0)
If MsgBox("Are you sure you want to delete this?",
MsgBoxStyle.Question + MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
dr = dsShots.Tables("Shot").Rows.Find(iImage)
dsShots.Tables("Shot").Rows.Remove(dr)
daShots.Update(dsShots)
End If
What more do I need to do?
I have a datagrid (grdShots) on a form, and a button to allow the user
to delete records from the dataset underlying the grid. My code
appears to work, because the row disappears from the datagrid. But the
delete is not being updated back to the data source, because if I exit
the app then start it again, the record reappears in the grid - it has
not been deleted. Code for deleting the row is as follows. Column 0
in the grid is the ID of the record, which is its primary key.
Dim iImage as Long
Dim dr as DataRow
iImage = grdShots.Item(grdShots.CurrentRowIndex, 0)
If MsgBox("Are you sure you want to delete this?",
MsgBoxStyle.Question + MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
dr = dsShots.Tables("Shot").Rows.Find(iImage)
dsShots.Tables("Shot").Rows.Remove(dr)
daShots.Update(dsShots)
End If
What more do I need to do?