Reading multiple recordsets
I have a Stored proc which returns 6 select statement results. I'm trying to use one record set to execute sp and get records for each select statement but i get 0 or empty records when i read them,
How can i query record set with multiple select statements from stored procedure?
ex:
Set rs = Server.CreateObject("ADODB.Recordset")
strSql = "Exec [dbo].[xyz] '"¶m1&"', '"¶m2&"', '"¶m3& "'"
rs.open strSql,CN,3,3
Do While Not rs.EOF
if rs.recordcount > 0 then
r1 = r开发者_如何学JAVAs.GetString(, , ", ", "<BR>" )
else
r1 = 0
end if
rs.MoveNext
Loop
Set rs = rs.NextRecordset()
Do While Not rs.EOF
if rs.recordcount > 0 then
r2 = rs.GetString(, , ", ", "<BR>" )
else
r2 = 0
end if
rs.MoveNext
Loop
rs.NextRecordset()
is the right way to get to the next recordset returned from a stored procedure or other command, so your code snipped should work.
What is not working for you?
As an aside, I hope the strSql
variable is not constructed the way you posted (strSql = "Exec [dbo].[xyz] '"¶m1&"', '"¶m2&"', '"¶m3& "'"
), as this is a clear SQL Injection vulnerability.
精彩评论