Click here to Skip to main content
15,559,962 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 vb.net. 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

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


Dim x As New Integer
cm.Parameters.Clear()

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)
Else
MsgBox("Coffee Deleted Failed!", vbCritical)


End If
Me.Dispose()
Catch ex As Exception
MsgBox(ex.Message)
End Try
cn.Close()
End If
End Sub
Posted
Updated 5-Nov-22 6:04am
v2

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