where clause in asp

They have: 426 posts

Joined: Feb 2005

I have to create a website in asp for an college assignment, however im having trouble writing a where clause.

The query below works

<%
Dim ORp
Set oRSp=server.createobject("ADODB.recordset")
sqltext="Select * from products"
orsp.open sqltext, "dsn=20509703"
%>
'

But when i add the where clause i get errors

<%
Dim ORp
Set oRSp=server.createobject("ADODB.recordset")
sqltext="Select * from products where cat_ID='1' "
orsp.open sqltext, "dsn=20509703"
%>
'

the error for this query is like this

Provider error '80004005'

Unspecified error

/20509703/test.asp, line 13

They have: 426 posts

Joined: Feb 2005

fixed it i enclosed the integer in single quotes cat_ID='1' where it should not be in single quotes, im guessing because it is an integer?

JeevesBond's picture

He has: 3,956 posts

Joined: Jun 2002

benf wrote: im guessing because it is an integer?

Yes that's correct. Am sure I've made the same mistake with ASP before too.

Just love the error reporting: 'Unspecified error', how helpful! Sticking out tongue

a Padded Cell our articles site!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.