here is my code for delete
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click If MsgBox("Are you sure you want to delete this item?", vbYesNo + vbQuestion, "Delete") = vbNo Then Else If Me.DataGridView1.Rows.Count > 0 Then If Me.DataGridView1.SelectedRows.Count > 0 Then Dim x As Integer = Me.DataGridView1.SelectedRows(0).Cells("FNo").Value If Not cnn.State = ConnectionState.Open Then cnn.Open() End If 'delete data Dim cmb As New OleDb.OleDbCommand cmb.Connection = cnn cmb.CommandText = "DELETE FROM Food WHERE FNo=" & x cmb.ExecuteNonQuery() 'refresh data Me.RefreshData() 'close connection cnn.Close() End If End If End If End Sub
it keep showing me error that Column named FNo cannot be found. in my access database, i have Fno as primary key, foodname and food price.