Click here to Skip to main content
15,846,038 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi! can you tell me what's wrong in this code? Incase of deleting the selecting row , the message keeps showing that 'coffee deleted failed". Hope you can help me. I'm using Thankyou.

What I have tried:

Sub delete()
If MessageBox.Show("ARE YOU SURE YOU WANT TO DELETE THIS RECORD?", "TIPAS FOODCOURT KIOSK", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then

cm = New OleDbCommand("DELETE FROM tblmerchant WHERE DESCRIPTION=@DESCRIPTION", cn)

Dim x As New Integer

cm.Parameters.AddWithValue("@DESCRIPTION", descrip.Text)
x = cm.ExecuteNonQuery
If x > 0 Then
MessageBox.Show("YOUR RECORD IS SUCCESFULLY DELETED", "TIPAS FOODCOURT KIOSK", MessageBoxButtons.OK, MessageBoxIcon.Information)
MsgBox("Coffee Deleted Failed!", vbCritical)

End If
Catch ex As Exception
End Try
End If
End Sub
Updated 5-Nov-22 6:04am

1 solution

We can't tell - we have no idea what is in the textbox.

If no rows are deleted, then that means that no rows match your criteria: WHERE DESCRIPTION=@DESCRIPTION. So start with the debugger and see exactly what descrip.Text contains, then use the appropriate app to look at your datasource, and find what values the description column contains.

We can't do any of that for you: we have no access to your data, or your code while it is running!
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900