Click here to Skip to main content
15,913,341 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dim RouteID As String

 Dim Response As Integer
        RouteID = InputBox("Enter the Route ID of the record to be deleted ")
       

        
        If RouteID <> And Not Regex.IsMatch(RouteID, "[a-z]") Then
            ' Displays a message box with the yes and no options.

            Response = MsgBox(Prompt:="NOTE: Are you sure ?" & vbCrLf & "Deleting this record will erase data from database", Buttons:=vbYesNo)

            ' If statement to check if the yes button was selected.
            If Response = vbYes Then
                con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\jai shri krishna\My Documents\Busmanagement.mdb")
                con.Open()


                str = "DELETE FROM RouteDetails WHERE RouteID = '" + RouteID + "'"

                cmdDelete = New OleDbCommand(str, con)
                cmdDelete.ExecuteNonQuery()' getting error datatype mismatch in criteria expression 
                cmdDelete.Dispose()
                MsgBox("Record Deleted")
Posted
Updated 12-Apr-13 11:02am
v2
Comments
Richard C Bishop 12-Apr-13 17:03pm    
You probably want RouteID to be an int. Then remove the ' ' from your Delete statement that surrounds the RouteID in your Where clause.
Polarfuze 12-Apr-13 18:35pm    
Thank you that helped
Richard C Bishop 15-Apr-13 13:55pm    
You are welcome.

1 solution

If ID is numeric value (not text), use

VB
str = "DELETE FROM RouteDetails WHERE RouteID = " & RouteID 


To concatenate strings in VB.NET use "&" instead of "+"
 
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