delete row from datatable
I can add rows and it automatically updates, work fine.
but when i try to delete a row, some can be delete some cant. but after all when I reload the list everything is unchanged..
Code:
Dim response = MsgBox("Are you sure?", 4 Or 32, "")
If response = MsgBoxResult.Yes Then
rownum = SCD_allowedDataGrid.CurrentRowIndex
SCD.SCD_allowed.Rows(rownum).Delete()
Me.SCD_allowedDataGrid.Update()
End If
then i try this: i got an error " Update requires a valid DeleteCommand when passed DataRow collection with deleted rows."
ok...i think i need a deletecommand.
DELETE FROM [SCD allowed]
WHERE ???? <<< what do i put here if i want to delete a selected row?
Code:
Dim response = MsgBox("Are you sure?", 4 Or 32, "")
If response = MsgBoxResult.Yes Then
rownum = SCD_allowedDataGrid.CurrentRowIndex
SCD.SCD_allowed.Rows(rownum).Delete()
Me.SCD_allowedTableAdapter.Update(SCD.SCD_allowed)
End If
Re: delete row from datatable
Hey,
Have a look at this very useful post here:
http://www.vbforums.com/showthread.php?t=469872
It shows you exactly how to go about doing this.
Hope this helps!!
Gary
Re: delete row from datatable
Quote:
Originally Posted by gep13
but i mean to delete a row by currentselectedrow in a tableadapter?
Re: delete row from datatable
I am not sure what you mean.
Have you created the DeleteCommand as per the post that I linked you to?
Deleting a row from the disconnected version of the data does not persist it through to the database, that is why you are seeing it re-appear. The only way to ensure that the data is deleted in the database is to use the DeleteCommand, and how to do this is shown in the link.
Gary