"Data type mismatch in criteria expression" in SQL statement
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: "Data type mismatch in criteria expression" in SQL statement

Threaded View

  1. #1
    Join Date
    Jun 2012
    Posts
    13

    "Data type mismatch in criteria expression" in SQL statement

    hey there,

    Here's my complete code for a delete button that deletes a record in a Hierarchical Flex Grid.

    Code:
        Dim rsTour As New ADODB.Recordset
        Dim cn As New ADODB.Connection
        Dim strSQL As String
        cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
          "Data Source=" & App.Path & "\Luckshan Tours & Travels.mdb;" & _
          "Persist Security Info:False"
        cn.Open
        msg = MsgBox("Delete Record?", vbYesNo)
        If msg = vbYes Then
          strSQL = "Delete From Tour Where [Tour ID] = '" & fgdTour.TextMatrix(fgdTour.Row, 1) & "'"
          cn.Execute strSQL
          strSQL = "Select * From Tour"
          rsTour.Open strSQL, cn, adOpenStatic, adLockPessimistic
          Set fgdTour.DataSource = rsTour
        End If
        Set fgdTour.DataSource = rsTour
        If rsTour.RecordCount <> 0 Then
          rsTour.Update
        End If
    The code works great for two of my forms, but for the other two it doesn't. It gives me an error saying "Data type mismatch in criteria expression" and highlights the statement :

    Code:
    cn.Execute strSQL
    Please help.... I've gone over and over the code for errors but could find none, I mean it works perfectly for the other two forms.
    Last edited by WizBang; June 28th, 2012 at 04:03 PM. Reason: Formatted code with indentation for clarity

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center