With this routine we can delete multiple selected rows with only a clic maybe after a search in the table:
Private Sub DeleteSelecedRows()
Dim ObjConnection As New FbConnection()
Dim i As Integer
Dim mResult
mResult = MsgBox("Want you really delete the selected records?", _
vbYesNo + vbQuestion, "Removal confirmation")
If mResult = vbNo Then
Exit Sub
End If
ObjConnection.ConnectionString = _ "servertype=0;username=sysdba;password=masterkey;database=" & My.Application.Info.DirectoryPath & "\mydb.gdb"
Dim ObjCommand As New FbCommand()
ObjCommand.Connection = ObjConnection
For i = Me.DataGridView1.SelectedRows.Count - 1 To 0 Step -1
ObjCommand.CommandText = "delete from mytable where counter='" & _ DataGridView1.SelectedRows(i).Cells("counter").Value & "'"
ObjConnection.Open()
ObjCommand.ExecuteNonQuery()
ObjConnection.Close()
Me.DataGridView1.Rows.Remove(Me.DataGridView1.SelectedRows(i))
Next
End Sub
Deleting multiple selected rows in a datagridview with only a clic
Posted by Giovanni G Edit
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment