Hi guys. Im trying to delete a row from a table in DataGridView (VB 2010) and my database (MS Access 2013) but on "Delete" it shows that it doesnt get the ID of that data row, so it wouldnt actually know what data to "Delete"
delete btn:
Private Sub btn_dlt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_dlt.Click
Dim delete_confirmation = MsgBox("Are you sure you would like to delete the product '" & currentpid & "'?", MsgBoxStyle.YesNo)
If delete_confirmation = MsgBoxResult.Yes Then
run_sql_query("DELETE FROM TBL_PRODUCTS_A154287 WHERE FLD_PRODUCT_ID = '" & currentpid & "'")
Beep()
MsgBox("The product '" & currentpid & "' has been successfully deleted.")
End If
End Sub
initializing currentpid as public
Dim currentpid As String
currentpid :
Private Sub getProductID()
Dim current_row As Integer = grd_list.CurrentRow.Index
currentpid = grd_list(0, current_row).Value
//TO TEST IF ID AND NAME IS READ
txt_id.Text = currentpid
txt_pname.Text = grd_list(1, current_row).Value
End Sub
Private Sub grd_list_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles grd_list.CellContentClick
getProductID()
End Sub