Error: Microsoft JET Database Engine (0x80040E07)

J

John Davis

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
 
A

Alan

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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top