Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - I keep getting "Data type mismatch in criteria
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

I keep getting "Data type mismatch in criteria

 Post Reply Post Reply
Author
urko View Drop Down
Groupie
Groupie
Avatar

Joined: 23 September 2004
Location: Slovenia
Status: Offline
Points: 160
Post Options Post Options   Thanks (0) Thanks(0)   Quote urko Quote  Post ReplyReply Direct Link To This Post Topic: I keep getting "Data type mismatch in criteria
    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


Edited by urko - 20 September 2006 at 8:11pm
Urko
Back to Top
Freon22 View Drop Down
Groupie
Groupie


Joined: 04 December 2005
Status: Offline
Points: 42
Post Options Post Options   Thanks (0) Thanks(0)   Quote Freon22 Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post 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"))
Back to Top
MadDog View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 01 January 2002
Status: Offline
Points: 3008
Post Options Post Options   Thanks (0) Thanks(0)   Quote MadDog Quote  Post ReplyReply Direct Link To This Post 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 ;'.
Back to Top
urko View Drop Down
Groupie
Groupie
Avatar

Joined: 23 September 2004
Location: Slovenia
Status: Offline
Points: 160
Post Options Post Options   Thanks (0) Thanks(0)   Quote urko Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.