How to count rows in DBgrid/DataGrid


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: How to count rows in DBgrid/DataGrid

  1. #1
    Michael L Guest

    How to count rows in DBgrid/DataGrid


    hi,
    i need to know how to count the number of rows in a DBgrid of
    VB 5.0 or rows of a DataGrid in VB 6.0?

    i know how many columns i have, but the number of the rows can change depending
    on input.

    please post code

    -Michael L

  2. #2
    Aleksandr Guest

    Re: How to count rows in DBgrid/DataGrid


    Since DBGrid and DataGrid are DataBound controls, they are attached to a datacontrol.
    You can know the number of rows of your recordset with the RecordCount property,
    it is the number of rows in your Grid.

    Aleksandr

    "Michael L" <mordy3eb@hotmail.com> wrote:
    >
    >hi,
    >i need to know how to count the number of rows in a DBgrid of
    >VB 5.0 or rows of a DataGrid in VB 6.0?
    >
    >i know how many columns i have, but the number of the rows can change depending
    >on input.
    >
    >please post code
    >
    >-Michael L



  3. #3
    Brent Guest

    Re: How to count rows in DBgrid/DataGrid


    Be carefule here. If you are using ADO the RecordCount property may sometimes
    return -1... pretty cool huh! Yep you got some records!

    If this occurs the only solution I've been able to come up with is looping
    through the recordset until EOF and increment a counter.

    HTH
    Brent

    "Aleksandr" <aleks@famcolorado.net> wrote:
    >
    >Since DBGrid and DataGrid are DataBound controls, they are attached to a

    datacontrol.
    >You can know the number of rows of your recordset with the RecordCount property,
    >it is the number of rows in your Grid.
    >
    >Aleksandr
    >
    >"Michael L" <mordy3eb@hotmail.com> wrote:
    >>
    >>hi,
    >>i need to know how to count the number of rows in a DBgrid of
    >>VB 5.0 or rows of a DataGrid in VB 6.0?
    >>
    >>i know how many columns i have, but the number of the rows can change depending
    >>on input.
    >>
    >>please post code
    >>
    >>-Michael L

    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center