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.

Re: Use of DCount in ASP by Ronx

Ronx
Fri Feb 29 03:00:13 CST 2008

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


--
Ron Symonds - Microsoft MVP (FrontPage)
Reply only to group - emails will be deleted unread.

http://www.rxs-enterprises.org/fp




"jimt" <jimt@discussions.microsoft.com> wrote in message
news:C88FECC7-4B33-4C49-9CD1-A74E3D2A77CA@microsoft.com:

> 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.