TDBAdvGrid prevents me to use dataset filtering

I use a briefcase model for conneting to a databse. Meaning, I load dataset records into memory and then disconnect from the connection until I use AppyUpdates..

void ReadTable(TADOTable* MyTable, TADOConnection* MyCon){
    MyTable->Close();  // just in case...
    try{
        MyCon->Open();
    }
    catch(...){
        Application->MessageBoxA(L"Cannot access database!", L"Error", 0 | MB_ICONSTOP);
        Application->Terminate();
    }
    MyTable->Connection = MyCon;
    MyTable->Open();
    MyTable->Connection = NULL; // Causes problems with TDBAdvGrid when PageMode = true !
    MyCon->Close();
}

I put TDBAdvGrid (PageMode = true) on the form and then I load my AdoTable into memory:

void __fastcall TForm1::FormCreate(TObject *Sender){
    ReadTable(ADOTable1, ADOConnection1);
}

Problem begins when trying to use dataset filtering because it seams TDBAdvGrid does not load all records from the dataset. That is also confirmed in the manual:

"The grid will load a new page of rows when it is scrolled to a previous or next page."

So, after I define dataset filtering and try to set dataset filter = true I get "Missing Connection or ConnectionString". Now.. if you stated that PageMode = true works with dataset then I need for this to work as well. So, I need TDBAdvGrid to load ALL records from the dataset without setting PageMode to false. Is this possible? Also, I need it because when I use dataset search (AdoTable->Locate) TDBAdvGrid usually points me to the result but it does not load all the records on that page and it looks deformed.

Using TDBGrid everything works just fine.


Hi,
I think it's standard behavior of the VCL datasets to not load the full range of datasets and most likely to also error on closed connections (DBAdvGrid uses regular TDatalink).
Have your tried

MyTable->Last();

MyTable->First();


after the Open to receive all rows?

Also, have you looked into using TClientDataset?

Regards,
Tobias


I have tried

AdoTable1->Last();
AdoTable1->First();

but it does not have any effect. I cannot change to TClientDataset since I have more then 30 Ado tables and it's to much work just because TDBAdvGrid. I wanted to change these TDBGrids so app could have a modern look using TDBAdvGrid but my code should work regardless DBGrid that I use. And like I said, it works just fine when using TDBGrid, so i dont think it's about anything else then a TDBAdvGrid.

Thanks

Did you try to set grid.DataSetType = dtNonSequenced ?


Please note that TDBAdvGrid has no relationship with TDBGrid. It does not inherit from TDBGrid nor has the intention to be a fully compatible replacement for it.



Thanks! This solved my problem.