Click here to Skip to main content
11,705,208 members (42,575 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Access VB.NET
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 12-Apr-13 11:01am
Edited 12-Apr-13 11:02am
v2
Comments
richcb at 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 at 12-Apr-13 18:35pm
   
Thank you that helped
richcb at 15-Apr-13 13:55pm
   
You are welcome.

1 solution

Rate this: bad
good
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 "+"
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 550
1 OriginalGriff 244
2 ppolymorphe 126
3 CPallini 82
4 F-ES Sitecore 70
0 OriginalGriff 8,988
1 Sergey Alexandrovich Kryukov 8,272
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,606


Advertise | Privacy | Mobile
Web01 | 2.8.150819.1 | Last Updated 12 Apr 2013
Copyright © CodeProject, 1999-2015
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