Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 ASP: Returning records from a stored proc

Author  Topic 

Huligan
Yak Posting Veteran

66 Posts

Posted - 2004-06-29 : 12:51:58
I'm going to start by saying I think this is a dumb question, but I have not been able to find the VBScript I need in order to make this work. I have a stored procedure that returns 0 to many records and it works very well.

My problem is I can't find the ASP syntax I need in order to call the recordset from the stored procedure so I can work with the data in VBScript. I can call data from the stored proc as if it is one record and that gives me the column value of the last record every time.

Do I need a loop to capture this? Is it stored in an array? I have checked several ASP sites for example code, but haven't found something that worked for me. I just need to be pointed to some example ASP code that will show me how more than one record is pulled from a stored procedure.

Thanks for your help and patience.

Huligan

nr
SQLTeam MVY

12543 Posts

Posted - 2004-06-29 : 13:01:08
You retieve a resultset and mve through that row by row.

see
http://www.nigelrivett.net/DBAccess.inc.html

This will retrieve an ado recordset which you can access via

do while not rs.eof
request.write rs("myfld1")
request.write rs("myfld2")
rs.movenext
loop

rs.close
set rs = nothing

Appologies for incorrect asp but...

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-06-29 : 13:47:22
Huligan, there's also a "Move to next RecordSet" ability - which you might need if your SProc outputs more than one SELECT.

(Nigel I think you'll find that ASP works better using RESPONSE.write rather than REQUEST.write - I think you're trying to feed those punch cards into the Printer again!)

Kristen
Go to Top of Page

Huligan
Yak Posting Veteran

66 Posts

Posted - 2004-06-29 : 14:01:59
Thanks nr and Kristen. I'm very familiar with the RS1.NextRecordset() and will use it if I need to. I think nr has bridged the gap I needed by providing the syntax to turn the stored proc data into a recordset. I haven't had a chance to try it yet, but it looks good.

Thanks again.

Huligan
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-06-29 : 16:55:38
>> Nigel I think you'll find that ASP works better using RESPONSE.write rather than REQUEST.write
So that's why that systems not working :).

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Huligan
Yak Posting Veteran

66 Posts

Posted - 2004-06-30 : 14:24:21
Thanks Nigel. I figured out your functions and got my code working. Thanks again for the help.

Huligan
Go to Top of Page
   

- Advertisement -