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

Members online

No members online now.

Forum statistics

Threads
473,913
Messages
2,570,027
Members
46,421
Latest member
WaylonBran

Latest Threads

Top