Use of DCount in ASP

J

jimt

I'm using Frontpage 2000 with connection to an Access 2000 DB. I open a
connection to a stored query in the DB. After the Set command to execute the
query I would like to test for the number of records before writing the data
to the web page. If no records are returned I would skip over that section of
the html code.

I've tried using a DCount function for the record check but get an error
(unable to display the page). The following is an example of the type of code
I'm using:

where_stmt = "Where mykeyfld"
SQL_stmt = "Select * " & _
"From my_stored_query" & _
where_stmt

Set rs_xyz = connOLEDB.execute(SQL_stmt)

record_check = DCount("*", rs_xyz)
(this is where it errors out)

If record_check > 0 Then
etc.

1. Does VBScript allow the use of DCount?
2. If so, what is incorrect with the above code?
3. If not, is there an alternative other than counting the record via a
where loop?

Thanks
Jim T.
 
R

Ronx

Try:

set rs_xyz = connOLEDB.execute(SQL_stmt)
If not rs_xyz.EOF then
'do stuff with record set
else
response.write "No records returned"
end if
 

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

Similar Threads


Top