Getting count from SqlDataReader

Results 1 to 3 of 3

Thread: Getting count from SqlDataReader

  1. #1
    Tommy McConnell Guest

    Default Getting count from SqlDataReader

    Is it possible to get the count of rows from SqlDataReader, if not what is the best way to get it?<BR><BR>Thanks in advance,<BR><BR>Tommy McConnell

  2. #2
    AgentBxb Guest

    Default RE: Getting count from SqlDataReader

    Hi Tommy Here&#039;s a simple solution for you<BR><BR>Dim i As Integer<BR><BR> Do While ds.Read<BR> i += 1<BR> Loop<BR><BR>Response.Write(i)

  3. #3
    Tommy McConnell Guest

    Default RE: Getting count from SqlDataReader

    Thanks for the help. I created a function to do the worka nd return an integer.<BR>&#039;reader is a SqlDataReader object<BR>FUNCTION getRowCount(reader) AS Integer<BR> DIM i AS Integer<BR> i = 0<BR> DO WHILE reader.Read()<BR> i += 1<BR> LOOP<BR> RETURN i<BR>END FUNCTION<BR><BR>Only problem is resetting the SqlDataReader back to first record. As of now i just rerun the query.<BR><BR>Thanks again,<BR><BR>Tommy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts