Private Sub DataGridView1_CellDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
Dim sql4, sql5, sql6, sql7 As String
Dim userkeys = DataGridView1.Rows.Item(e.RowIndex).Cells(6).Value.ToString()
If MsgBox("คุณต้องการลบข้อมูล?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
sql4 = "DELETE FROM Invoice where 'Part no=" & userkeys & "'"
command = New OleDbCommand(sql4, conn)
command.ExecuteNonQuery()
sql5 = "DELETE FROM Invoicetag where 'Part no=" & userkeys & "'"
command1 = New OleDbCommand(sql5, conn)
command1.ExecuteNonQuery()
DataGridView1.DataSource.clear()
sql6 = " select * from Invoice"
da = New OleDbDataAdapter(sql6, conn)
da.Fill(ds, "s")
sql7 = " select * from Invoicetag"
da = New OleDbDataAdapter(sql7, conn)
da.Fill(ds, "s")
DataGridView1.DataSource = ds.Tables("s")
MessageBox.Show("ลบข้อมูลเรียบร้อย")
End If