Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


moving through recordset with multiple sets

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,58490
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> moving through recordset with multiple sets
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 moving through recordset with multiple sets - 3/28/2008 2:20:23 AM   
  sidlet

 

Posts: 1
Score: 0
Joined: 3/28/2008
Status: offline
All,

I'm having some problems dealing with a VB script which delivers multiple results back from SQL Server.  The script opens a connection to SQL 2000 and executes a procedure.  The stored procedure has five select statements for its result.  I receive a recordset object and try to move through each resultset.  I get the first two result sets but when I execute the rs.nextrecordset on the third result, the rs.EOF is set to true and I never receive the third through fifth result set.  The only difference I see from the stored procedure is that the first two result sets are "Select"s from local variables (ie @headertxt) and the third through the fifth result set are "Select"s from temporary (#tmptble) tables.  I can't determine the root cause of why I can't see the third though fifth result set.  I have "set nocount on" in the procedure.  I have executed the stored procedure in Query Analyzer under the same ID/PW that I'm setting the connection with in the VBS.  No errors are generated from the execution of the stored procedure.  I'm running MDAC 2.81 on the workstation. 
VBS:

dim Conn, strProvider, rs, SQL, i, j
dim asoftime, errorcode, cur1, cur2, atype, asofdate, display_title

'Get the data

Set Conn = Wscript.CreateObject("ADODB.Connection")

Conn.CommandTimeout = 60
Conn.ConnectionTimeout = 60
dim datasource
datasource =
"ljcasement\ascap"


strProvider =
"Provider=SQLOLEDB; Data Source=" & datasource & "; Initial Catalog=s; User ID=frndis; Password=frndis1; Connect Timeout=15; Persist Security Info=True;UseProcForPrepare=0"

SQL =
"exec s.dbo.prcWebGetMostActiveSongs @currency = 'USD'"


Conn.Open strProvider

Set rs = Conn.Execute(SQL)

asoftime = rs(0)

wscript.echo asoftime, rs.Fields.Count

set rs = rs.nextrecordset
cur1 = rs(0)
cur2 = rs(1)
atype = rs(2)
display_title = replace(rs(3),
"&", "&amp;")


wscript.echo cur1
wscript.echo cur2
wscript.echo atype
wscript.echo display_title, rs.Fields.Count

set rs = rs.nextrecordset

wscript.echo rs.Fields.Count

'grand total

while (not rs.eof)
for i = 0 to rs.Fields.Count - 1
wscript.echo rs(i)
next


rs.movenext

wend

wscript.echo
"finished grand"


set rs = rs.nextrecordset
'mostactive total

while (not rs.eof)

rs.movenext

wend

wscript.echo
"finished MA"


set rs = rs.nextrecordset
i = 0
'details

while (not rs.eof)
i = i + 1
rs.movenext

wend

wscript.echo
"finished details", i


rs.close
Conn.Close
set rs = nothing

set Conn = nothing



Thanks,
Sid
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> moving through recordset with multiple sets Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts