I want to let others to delete selected row in the following datagrid view,
and i have written it like this.
Now when i select a row and press the delete button i can remove the selected row
but it will not update the database which meant it will not deleting the
above row.
What could be the reason and just one thing.
I have bound my datagrid view using databinding.
Please anyone can help me on this....
Private Sub dgvAllInvoices_UserDeletingRow(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowCancelEventArgs) Handles dgvAllInvoices.UserDeletingRow
If MessageBox.Show("Do you really want to Delete this Invoice ?", "SD Technology", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.Yes Then
Try
Dim table As New DataTable()
Me.bindingSource = Me.dgvAllInvoices.DataSource
table = Me.bindingSource.DataSource
Me.dataAdapter.Update(table)
MsgBox("Selected Invoice has been deleted", MsgBoxStyle.Information, "SD Technology")
Catch ex As Exception
MsgBox("Cannot delete the above Invoice : Please contact the system administrator", MsgBoxStyle.Critical, "SD Technology")
End Try
Else
e.Cancel = True
Exit Sub
End Sub