Print Page | Close Window

I keep getting "Data type mismatch in criteria

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=21354
Printed Date: 29 March 2026 at 8:42am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: I keep getting "Data type mismatch in criteria
Posted By: urko
Subject: I keep getting "Data type mismatch in criteria
Date Posted: 20 September 2006 at 8:09pm
Hi..

I did my search but just couldnt fix my problem.

If my rs looks like that

strSQL = "SELECT * FROM OGLASI WHERE Approve=true ;"


it works fine.

But coz this si detail page i needed to select the ID's.

So when i write it like that

Dim IntOID
IntOID = Request.QueryString("OID")

strSQL = "SELECT * FROM OGLASI WHERE 'OID = " & IntOID & " AND Approve=true ;"


Then i get this errror:

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in string in query expression ''OID = '' AND Approve=true ;'.
/mysite/_INC_test.asp, line 37

following code is on line 37:
oglasRS.Open strSQL, adoCon


Thanks in advance..Wink


-------------
Urko



Replies:
Posted By: Freon22
Date Posted: 20 September 2006 at 10:01pm
Originally posted by urko urko wrote:

 
Dim IntOID
IntOID = Request.QueryString("OID")

strSQL = "SELECT * FROM OGLASI WHERE 'OID = " & IntOID & " AND Approve=true ;"


Then i get this errror:

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in string in query expression ''OID = '' AND Approve=true ;'.
/mysite/_INC_test.asp, line 37
 
One thing you may want to do is Response.Write(strSQL) to see what your query looks like.
 
If OID from your querystring in an integer "number" not a string.
 
Dim IntOID
IntOID = Cint(Request.QueryString("OID"))
strSQL = "Select * From OGLASI Where OID = " & IntOID & " And Approve = True;"
 
If its a string not an integer then try this.
 
Dim IntOID
IntOID - Request.QueryString("OID")
strSQL = "Select * From OGLASI Where OID = '" & IntOID & "' And Approve = True;"
 
One last thing OID is a field in your database table right?


Posted By: michael
Date Posted: 21 September 2006 at 4:56pm
You also seem to have a quote before OID=, that should not be there and to make sure oid is a number use CInt(Request.QueryString("OID"))

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: MadDog
Date Posted: 22 September 2006 at 2:57am
I would like to point out that the error message tells you wants wrong...

Quote [Microsoft][ODBC Microsoft Access Driver] Syntax error in string in query expression ''OID = '' AND Approve=true ;'.


-------------
http://www.iportalx.net" rel="nofollow">


Posted By: urko
Date Posted: 22 September 2006 at 8:43am
Thanks for answers...

I fixed it.

Problem was that instead of OID i had to write CID....
OID is a autonumber for ads and CID is for catID.

I wanted to go to detail page of categories where subcats are shown for each main category....

I didnt see it until yesterday when I was checking my code again...
and quote before OID was the problem too.

Oh....i feel so stupid....Wacko



-------------
Urko



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net