Results 1 to 2 of 2

Thread: Get the number or rows in a table

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    15

    Get the number or rows in a table

    Hi

    Im using an Access database however im unsure on how to loop through every row in the table.

    I have the following function, which works great - but as you can see it will only display the first 50 rows in the table. How do i loop through all the rows if i dont know how many rows there are!?

    VB Code:
    1. Private Sub printAllRows()
    2.         For u As Integer = 0 To 50 Step 1
    3.             lbProductData.Items.Add(m_dtProducts.Rows(u)("ProductName").ToString())
    4.         Next
    5.     End Sub

    Thanks, Reeksy.

  2. #2
    Hyperactive Member nagasrikanth's Avatar
    Join Date
    Nov 2004
    Location
    India,Hyderabad.
    Posts
    420

    Re: Get the number or rows in a table

    simple....use EOF function...

    example:

    VB Code:
    1. public function printallrows()
    2. {
    3.   while not rst.eof    ' uptill end of rows of record set....
    4.  
    5.   msgbox rst(0)        ' Print Recordset
    6.  
    7.   rst.movenext         ' move to next record
    8.   wend
    9. }

    try it...hope it will resolve the issue...All the best
    The Difference between a Successful person and others is not a Lack of Knowledge,
    But rather a Lack of WILL

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