Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2004
    Posts
    13

    Angry Unanswered: Data type mismatch in criteria expression

    Hi all,
    Here is my code :-

    Code:
    <%
    
    Dim oADO, oRS, sSQL
    Dim sUserID, sPassword
    
    sStd_ID = Request.Form("txtStd_ID")
    sStd_pwd = Request.Form("txtStd_pwd")
    
    
    sSQL = "SELECT Quizes,Midterm1,Midterm2,Final,Bonus,Grade FROM [sheet1$] 
    WHERE [Std_ID]='" & q(sStd_ID) & "' AND [Std_pwd]='" & q(sStd_pwd) & "'"
    Set oADO = CreateObject("ADODB.Connection")
    oADO.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data 
    Source=D:\Path\To\This\File.xls;Extended Properties=""Excel 
    8.0;HDR=Yes;IMEX=1"""
    
    Set oRS = oADO.Execute(sSQL)
    If oRS.EOF Then
    Response.Write "Login failed."
    Else
    %>
    <table>
    <tr>
      <th>quizzes</th>
      <th>Midterm 1</th>
      <th>Midterm 2</th>
      <th>final</th>
      <th>bonus</th>
      <th>grade</th>
    </tr>
    
    <tr>
      <td><%=oRS.Fields.Item(0).Value%></td>
      <td><%=oRS.Fields.Item(1).Value%></td>
      <td><%=oRS.Fields.Item(2).Value%></td>
      <td><%=oRS.Fields.Item(3).Value%></td>
      <td><%=oRS.Fields.Item(4).Value%></td>
      <td><%=oRS.Fields.Item(5).Value%></td>
    </tr>
    </table>
    <%
    End If
    oRS.Close : Set oRS = Nothing
    oADO.Close : Set oADO = Nothing
    
    
    Function q(s)
    q = Replace(s, "'", "''")
    End Function
    %>
    As you can see its linked to Excel sheet and when I try to execute the code it gives me this error :-

    Technical Information (for support personnel)

    Error Type:
    Microsoft JET Database Engine (0x80040E07)
    Data type mismatch in criteria expression.
    /results.asp, line 16

    Line 16 is :-
    Set oRS = oADO.Execute(sSQL)


    what do you think the problem is ?
    Last edited by Q80-DB; 07-26-04 at 13:59.

  2. #2
    Join Date
    Jun 2004
    Posts
    13
    Hello there ...
    thanks anyway I found the problem its about the single quotes '' I should've taken them out because am using numric characters for Std_ID and Std_pwd

  3. #3
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    Well thanks for letting us all know what the answer was anyways...
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

Posting Permissions

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