Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Checking whether a recordset has or hasn’
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Checking whether a recordset has or hasn’

 Post Reply Post Reply
Author
pnp! View Drop Down
Newbie
Newbie


Joined: 04 October 2002
Location: Argentina
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote pnp! Quote  Post ReplyReply Direct Link To This Post Topic: Checking whether a recordset has or hasn’
    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!

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
pnp! View Drop Down
Newbie
Newbie


Joined: 04 October 2002
Location: Argentina
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote pnp! Quote  Post ReplyReply Direct Link To This Post 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!

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 24 July 2003 at 3:18pm
rs = cn.Execute(txtSP)
should be
Set rs = cn.Execute(txtSP)
Back to Top
pnp! View Drop Down
Newbie
Newbie


Joined: 04 October 2002
Location: Argentina
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote pnp! Quote  Post ReplyReply Direct Link To This Post 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!

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.