ppitu
ppitu

Reputation: 41

C++ Builder Convert TIBQuery to TIBTable

How to convert TIBQuery to TIBTable, additionally to display it in DBGrib? I want to sort data in DBGrid and I used TIBQuery to take sort data from database, and I have problem to convert data from TIBQuery to TIBTable.

Upvotes: 1

Views: 121

Answers (1)

user186876
user186876

Reputation: 301

Create a VCL C++Builder app - Drop in TIBDatabase, TIBTable, TDataSource and TDBGrid on your form. Make active the TIBDatabase and TIBTable connections. Right mouse click on the TIBTable to add the columns you want to have appear in your TDBGrid. Leave the Column Header text to be the same as the Column Names.

Add the following line of code to the onTitleClick for the DBGrid:

void __fastcall TForm1::DBGrid1TitleClick(TColumn *Column)
{
    // set TIBTable's IndexFieldNames property to the column title field name
    // this will sort ascending all of the data in the DBGrid
    IBTable1->IndexFieldNames = Column->FieldName;
}

If you want to do even more, I suggest that you add a TDataSetProvider and TClientDataSet to your form and then you can do more with your app.

Upvotes: 1

Related Questions