Results 1 to 8 of 8

Thread: how to get record count in oledbdatareader

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    11

    how to get record count in oledbdatareader

    hi guys,
    i am using access as backend in my project. i'am able to retreive data from the database and assigning to textbox. but i wan't to know the no of records.
    is there anything just like rs.recordcount in vb6.0

    code:
    Dim dread As OleDbDataReader = cmd.ExecuteReader()

    While dread.Read
    data1.Text = dread(1)
    data2.Text = dread(2)
    data3.Text = dread(3)
    End While

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: how to get record count in oledbdatareader

    You can increment your counter in each iteration of the While dr.read loop, that'd give you the number of records.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    11

    Re: how to get record count in oledbdatareader

    Quote Originally Posted by mendhak
    You can increment your counter in each iteration of the While dr.read loop, that'd give you the number of records.
    thanx, i'll try

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    11

    Re: how to get record count in oledbdatareader

    thanx mendak
    but my problem is if dr is null i've to input the value otherwise it must take from dtabase. i wan't to check wether database is having any records or not. how to do it

  5. #5
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    Re: how to get record count in oledbdatareader

    VB Code:
    1. dim i as integer=0
    2.  While dread.Read
    3. data1.Text = dread(1)
    4. data2.Text = dread(2)
    5. data3.Text = dread(3)
    6. i+=1
    7. End While
    8. if i <= 0 then
    9. 'no records
    10. end if

  6. #6

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    11

    Re: how to get record count in oledbdatareader

    thanx
    problem solved

  7. #7

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    11

    Resolved Re: how to get record count in oledbdatareader

    Resolved

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: how to get record count in oledbdatareader

    Quote Originally Posted by kishorepv
    Resolved
    Edit the title and icon of your first post. That way it shows up on the thread listing for the forum section.

Posting Permissions

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



Click Here to Expand Forum to Full Width