title: Populate gridview with results of a SQL Server stored procedure that returns multiple recordsets
body: <p>I have a stored procedure that returns multiple recordsets. It can be 1 recordset, 2 recordsets, or more. I don't know how many RS will come back.</p>
  
  <p>Here at stackoverflow I found the below sample</p>
  
  <pre><code>    Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("myConnection").ConnectionString)
      Dim cmd As New SqlCommand
      Dim Reader As SqlDataReader
      cmd.Connection = conn
      cmd.Parameters.AddWithValue("@ACTNbr", tbACTNbr.Text.ToString.Trim)
      cmd.Parameters.AddWithValue("@WTHNbr", tbWTHNbr.Text.ToString.Trim)
      cmd.CommandText = "sp_search_def"
      cmd.CommandType = CommandType.StoredProcedure
      conn.Open()
      Reader = cmd.ExecuteReader()
  'The next part is what I found here at stackoverflow
  While Reader.Read() OrElse (Reader.NextResult() And Reader.Read())
    For i As Integer = 0 To Reader.FieldCount - 1
      Response.Write(Reader(i).ToString())
      Response.Write(" ")
    Next
    Response.Write("&lt;br /&gt;")
  End While
  </code></pre>
  
  <p>The above <code>response.write</code>'s show the data I need perfectly. But I need to put that into a Gridview. i.e. I need to put the results of the stored procedure (and all of its result sets) into one gridview.</p>
  
  <p>My gridview is set to <code>AutoGenerateColumns = "true"</code>.</p>
  
  <p>I've tried:</p>
  
  <pre><code>myGridview.DataSource = Reader
  myGridview.DataBind()
  </code></pre>
  
  <p>And of course I only get one of the recordsets.</p>
  
  <p>The results of the stored procedure are all formatted the same - same number of columns, headers, and so on.</p>
  
  <p>Can somebody point me in the right direction? I've been trying to figure this out, but give up and now I am asking here.</p>
  
  <p>I am new to this.</p>
  
  <p>Thank you.</p>