Print Page | Close Window

Checking whether a recordset has or hasn’

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=4499
Printed Date: 30 March 2026 at 10:07am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Checking whether a recordset has or hasn’
Posted By: pnp!
Subject: Checking whether a recordset has or hasn’
Date Posted: 24 July 2003 at 2:44pm

I've the following 'typical' connection, executing a stored procedure and putting it on a recordset

Set cn = Server.CreateObject("ADODB.Connection")
cn.open "Provider=SQLOLEDB; Data Source=localhost; Initial Catalog=Intranet;User Id=sa; Password=;"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open StoredProcedureName,1


I want to execute a Stored procedure that bring me some rows...
and I want to check whether it bring me rows or not....

but... as i try to do a rs.Recordcount, it raises an error.

How can I do it?

thanks in advance!




Replies:
Posted By: ljamal
Date Posted: 24 July 2003 at 2:59pm
Use rs.EOF as in
if rs.EOF then

If it's true and you have just opened the record set then there are no rows in the record set.

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: pnp!
Date Posted: 24 July 2003 at 3:08pm

Originally posted by ljamal ljamal wrote:

Use rs.EOF as in
if rs.EOF then

If it's true and you have just opened the record set then there are no rows in the record set.

 

Ok! thanks.. but when i do it I get the following error:


Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'EOF'


Here's my code:



Set cn = Server.CreateObject("ADODB.Connection")
cn.open "Provider=SQLOLEDB; Data Source=pecora3; Initial Catalog=Intranet;User Id=sa; Password=;"
Set rs = Server.CreateObject("ADODB.Recordset")
txtSP = "GetRed '110.40.11.0'"
rs = cn.Execute(txtSP)
if rs.EOF then
     Response.Write "No regs"
else
     Response.Write "1+ regs"
end if


Thanks!



Posted By: ljamal
Date Posted: 24 July 2003 at 3:18pm
rs = cn.Execute(txtSP)
should be
Set rs = cn.Execute(txtSP)

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: pnp!
Date Posted: 25 July 2003 at 7:11am

Originally posted by ljamal ljamal wrote:

rs = cn.Execute(txtSP)
should be
Set rs = cn.Execute(txtSP)

 

Thanks!! that was my  mistake!!!.... you've discovered it!!...

Now it works fine!




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