Error: Microsoft JET Database Engine (0x80040E07)

Discussion in 'ASP General' started by John Davis, Aug 26, 2003.

  1. John Davis

    John Davis Guest

    I don't understand when I do (2), it will throw the error when I run the
    ASP. (1) is working fine. Should I use a single quote between the string in
    SQL statement in ASP?

    (1) strSQL = "SELECT * FROM DATA WHERE id = " & strParm1
    (2) strSQL = "SELECT * FROM DATA WHERE id = " & "'" & strParm1 & "'"

    Error Type:
    Microsoft JET Database Engine (0x80040E07)
    Data type mismatch in criteria expression.


    Please help. Thanks!
    John
     
    John Davis, Aug 26, 2003
    #1
    1. Advertisements

  2. John Davis

    Alan Guest

    What's the type of the underlying column? Integer types don't need
    delimiters:

    strSQL = "SELECT * FROM DATA WHERE id = " & strParm1

    Text types need single quotes:

    ' Note -- Different syntax than yours below.
    strSQL = "SELECT * FROM DATA WHERE id = '" & strParm1 & "'"

    Date types need a hash for Jet, singles quotes in SQL Server:

    ' Jet
    strSQL = "SELECT * FROM DATA WHERE id = #" & strParm1 & "#"

    ' SQL Server
    strSQL = "SELECT * FROM DATA WHERE id = '" & strParm1 & "'"

    Cheers,

    Alan
     
    Alan, Aug 26, 2003
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.