Data type mismatch in criteria expression.

D

Dave Lagergren

Code Snippet:
<% ' Now we open the Submission up to view it using the OrderNumber as the key

' Here we open the record and read in the fields
Dim SearchText, strQuery, strKey

SearchText = Request.QueryString("OrderNumber")

' OK, we get the variable Key passed ok, now let's read in the correct
record

Set objRS = Server.CreateObject("ADODB.Recordset")

Response.Write ">>>>>" & SearchText & "<<<<<"
objRS.Open "Select * from Results WHERE OrderNumber =" & 'SearchText',
objConn, 0, 1


Error:
Microsoft JET Database Engine error '80040e07'

Data type mismatch in criteria expression.

/logon/order_display.asp, line 48

Line 48 is the Open line.
 
T

Thomas A. Rowe

If the OrderNumber is a AutoNumber field, then change the following to read as:

objRS.Open "Select * from Results WHERE OrderNumber = " & SearchText


--
==============================================
Thomas A. Rowe
Microsoft MVP - FrontPage

http://www.Ecom-Data.com
==============================================
 
D

Dave Lagergren

Thomas, thanks for the feedback. Unfortunately OrderNumber is generated with
each new order and is not autonumber. I pass the variable to the program
from an email. I have tried SearchText =
CStr(Request.QueryString("OrderNumber")), SearchText =
CInt(Request.QueryString("OrderNumber")), SearchText =
Request.QueryString("OrderNumber") and they don't work. The variable is
passed but the line:

objRS.Open "Select * from Results WHERE OrderNumber =" & SearchText,
objConn, 0, 1

gives an error every time.
 

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

Top