title: multiple separate sql queries in one stored procedure
body: <p>I have need of many (16) different queries to get row count at the same time. I was running 16 different connections, but thought I could combine to just 1 stored procedure. </p>
  
  <p>I am having trouble as it gives error on datareader (system out of range excpection) for this line: </p>
  
  <pre><code>Count2 = Convert.ToInt32(objDRL("Row_Count2").ToString). 
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>Dim strConn As String = "Data Source=myDataSource"
      Dim Conn As New SqlConnection(strConn)
      Dim Cmd As New SqlCommand("adminStats", Conn)
      Cmd.CommandType = CommandType.StoredProcedure
      Dim objDRL As SqlDataReader
      Cmd.Parameters.Add(New SqlParameter("@campDate", "June 2014"))
      Conn.Open()
      objDRL = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
      If objDRL.HasRows Then
          While objDRL.Read()
              Count1 = Convert.ToInt32(objDRL("Row_Count1"))
              Count2 = Convert.ToInt32(objDRL("Row_Count2"))
              Count3 = Convert.ToInt32(objDRL("Row_Count3"))
              Count4 = Convert.ToInt32(objDRL("Row_Count4"))
              Count5 = Convert.ToInt32(objDRL("Row_Count5"))
              Count6 = Convert.ToInt32(objDRL("Row_Count6"))
              Count7 = Convert.ToInt32(objDRL("Row_Count7"))
              Count8 = Convert.ToInt32(objDRL("Row_Count8"))
              Count9 = Convert.ToInt32(objDRL("Row_Count9"))
              Count10 = Convert.ToInt32(objDRL("Row_Count10"))
              Count11 = Convert.ToInt32(objDRL("Row_Count11"))
              Count12 = Convert.ToInt32(objDRL("Row_Count12"))
              Count13 = Convert.ToInt32(objDRL("Row_Count13"))
              Count14 = Convert.ToInt32(objDRL("Row_Count14"))
              Count15 = Convert.ToInt32(objDRL("Row_Count15"))
  
  
          End While
      Else
  
      End If
  
      link1.Text = Count1.ToString
      link2.Text = Count2.ToString
      link3.Text = Count3.ToString
      link4.Text = Count4.ToString
      Link5.Text = Count5.ToString
      Link6.Text = Count6.ToString
      Link7.Text = Count7.ToString
      Link8.Text = Count8.ToString
      Link9.Text = Count9.ToString
      Link10.Text = Count10.ToString
      Link11.Text = Count11.ToString
      Link12.Text = Count12.ToString
      Link13.Text = Count13.ToString
      Link14.Text = Count14.ToString
      Link15.Text = Count15.ToString
  
      Conn.Close()
  </code></pre>
  
  <p>Stored procedure:</p>
  
  <pre><code>CREATE PROCEDURE adminStats 
      @campDate VARCHAR(20)
  AS
  BEGIN
      SELECT COUNT(*) AS Row_Count1 FROM Customer
      SELECT COUNT(*) AS Row_Count2 FROM campRegistration WHERE campDate = @campDate
      SELECT COUNT(*) AS Row_Count3 FROM campRegistration WHERE paidFull = 'True'
  
      SELECT COUNT(*) AS Row_Count4 FROM campRegistration WHERE shirtSize = 'S'
      SELECT COUNT(*) AS Row_Count5 FROM campRegistration WHERE shirtSize = 'M'
      SELECT COUNT(*) AS Row_Count6 FROM campRegistration WHERE shirtSize = 'L'
      SELECT COUNT(*) AS Row_Count7 FROM campRegistration WHERE shirtSize = 'XL'
      SELECT COUNT(*) AS Row_Count8 FROM campRegistration WHERE shirtSize = 'XXL'
  
      SELECT COUNT(*) AS Row_Count9 FROM campRegistration WHERE Staff = 'True'
  
      SELECT COUNT(*) AS Row_Count10 FROM campRegistration WHERE days = '1'
      SELECT COUNT(*) AS Row_Count11 FROM campRegistration WHERE days = '2'
      SELECT COUNT(*) AS Row_Count12 FROM campRegistration WHERE days = '3'
      SELECT COUNT(*) AS Row_Count13 FROM campRegistration WHERE days = '12'
      SELECT COUNT(*) AS Row_Count14 FROM campRegistration WHERE days = '23'
      SELECT COUNT(*) AS Row_Count15 FROM campRegistration WHERE days = '123'
  END
  GO
  </code></pre>