datareader problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vkas
    New Member
    • Feb 2009
    • 78

    datareader problem

    how to find out the total number of rows in a database through datareader
    any guide
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Well, what I would do is use another query:
    Code:
    Dim query as string = "select count(*) from table"
    Dim cmd as new SqlCommand(query,connection) 'use your existing connection
    cmd.Connection.Open
    Dim count as Int32
    count = cmd.ExecuteScalar()
    cmd.Connection.Close()

    Comment

    • Vkas
      New Member
      • Feb 2009
      • 78

      #3
      thanks!!!!!!
      but i have another question in my mind

      i had tried it worked!!!!!!!!! !!!!!
      but if i use a query

      Dim query as string = "select empid from table"

      only the 1st column of the table


      and i want retrieve all the values of the this column in a listbox

      then what should i do???????????/

      when i use execute scalar it return me a single value in the list box what about the others

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        Please read these two articles:




        They should get you started.

        Comment

        Working...