I have a stored procedure:
CREATE PROCEDURE [TestProc]
AS
BEGIN
select '1a', '1b'
select '2a', '2b', '2c'
select '3a', '3b'
END
If I execute the following query using SQL Management Studio,
exec TestProc
I get 3 result sets:
1. | 1a | 1b |
2. | 2a | 2b | 2c |
3. | 3a | 3b |
But when I use the stored procedure in ASP.NET(VB.NET),
Dim Connection As New SqlConnection(ConfigurationManager.ConnectionStrings("ConnToHilmarc").ToString)
Dim Command As New SqlCommand("exec TestProc @First, @Second", Connection)
Dim Reader As SqlDataReader
Command.Parameters.AddWithValue("@First", "Hello")
Command.Parameters.AddWithValue("@Second", "World")
Connection.Open()
Reader = Command.ExecuteReader
While Reader.Read
Response.Write(Reader(0) & " " & Reader(1) & "<br/>")
End While
Reader.Close()
Connection.Close()
I get only the first result set:
| 1a | 1b |
How can I get the three result sets using SqlDataReader? Or even three SqlDataReader's? Or is it possible to get multiple result sets in just one query in VB.NET? Is DataSet my only option? Thanks in advance.