Click here to Skip to main content
13,046,184 members (86,426 online)
Rate this:
Please Sign up or sign in to vote.
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")

                str = "DELETE FROM RouteDetails WHERE RouteID = '" + RouteID + "'"
                cmdDelete = New OleDbCommand(str, con)
                cmdDelete.ExecuteNonQuery()' getting error datatype mismatch in criteria expression 
                MsgBox("Record Deleted")
Posted 12-Apr-13 11:01am
Updated 12-Apr-13 11:02am
richcb 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
richcb 15-Apr-13 13:55pm
You are welcome.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If ID is numeric value (not text), use

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

To concatenate strings in VB.NET use "&" instead of "+"

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 12 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100