DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22

Thread: C++ Builder 6 - DBGrid

  1. #16
    Join Date
    Dec 2005
    Posts
    31
    Thank you very much.
    I will try it and I'll let you know.

    Kind Regards,
    Rowin

  2. #17
    Join Date
    Dec 2005
    Posts
    31
    I am a bit confused here.
    I need the TQuerry to write my SQL statement.
    I don't know if I can write my sql statement in a TTable.

    Is that right?


    Kind Regards,
    Rowin

  3. #18
    Join Date
    Apr 2006
    Location
    Zagreb, Croatia
    Posts
    152
    Hi Rowin,
    well I tried using TQuery->Last() method and then TQuery->RecordCount and it works. So first position your dataset to the last record and then call the recordcount property. AlSo note that using SELECT COUNT(*) in TQuery SQL property is more efficient then using RecordCount especially for large datasets.

  4. #19
    Join Date
    Dec 2005
    Posts
    31
    Hi Ivan,
    thanks a lot for your precious time and help.
    It worked!!

    Thanks again,
    Rowin

  5. #20
    Join Date
    Apr 2010
    Posts
    2
    A little late on that one, but since I struggled with a similar issue and found out how to get the number of selected rows (records), I thought I'd share.

    TDBGrid is linked to a TDataSet. TDataSet has protected members that would be very useful if you counld access them, such as RecNo (number of records in the data set) and ActiveCount (number of selected records/rows from the dbgrid).

    The trick is to expose them by using a derived class. In the following code, MyDBGrid is the TDBGrid object that is linked to a TDataSource component.

    Code:
    int __fastcall TMyDBClass::GetNumberOfSelectedRecords(TObject *Sender)
    {
        int numberOfSelectedRecords = 0;
    
        // Get the DataSet
        TDataSet *pDS = MyDBGrid->DataSource->DataSet;
    
        // Derived the base class TDataSet and expose the protected members
        class TExposedDataSet : public TDataSet { public: __property ActiveRecord; };
    
        // Return the number of selected records
        numberOfSelectedRecords = static_cast<TExposedDataSet*>(pDS)->ActiveRecord;
        return numberOfSelectedRecords;
    }
    You can do the same with any non-public member of the class you want to access.

    Hope this helps.

  6. #21
    Join Date
    May 2010
    Posts
    5
    Your post gave me some nice new thoughts - a very solid read.
    great comments specialy by Ivan
    good work..........keep it up
    zhu zhu pets
    Last edited by oracle; 05-17-2010 at 02:46 AM.

  7. #22
    Join Date
    Jan 2008
    Posts
    100
    I am really not a fan of the Data Grid, I find it much easier to just populate a String Grid control with my data manually.

    You will find you can do a lot more with it.

Similar Threads

  1. ListBot Going Out of Business
    By Larry Rebich in forum vb.announcements
    Replies: 1
    Last Post: 06-28-2001, 01:22 PM
  2. Help with Power Builder 6.0
    By dave in forum Database
    Replies: 0
    Last Post: 03-12-2001, 03:57 AM
  3. Get info from a Power Builder DataWindows
    By Javier Vargas in forum VB Classic
    Replies: 0
    Last Post: 11-01-2000, 09:29 AM
  4. Get info from a Power Builder DataWindows
    By Javier Vargas in forum VB Classic
    Replies: 0
    Last Post: 11-01-2000, 09:29 AM
  5. Field limeted in DBGrid V5.0 or V6.0
    By Goran in forum VB Classic
    Replies: 0
    Last Post: 06-16-2000, 08:19 AM

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