Lena Posted April 4, 2015 Share Posted April 4, 2015 Where more correct to open a database connection? In UniGUIMainModuleCreate or in UniFormShow? Thanks. //in UniMainModule void __fastcall TUniMainModule::UniGUIMainModuleCreate(TObject *Sender) { //FireDAC FDQuery1->Active = true; FDQuery1->FetchAll(); FDQuery1->First(); } //then in main form void __fastcall TMainForm::UniFormShow(TObject *Sender) { if(UniMainModule()->FDQuery1->RecordCount == 0) { ShowMessage(L"No data"); return; } UniMainModule()->ClientDataSet1->Active = true; } //************************************************* //Or all code in main form void __fastcall TMainForm::UniFormShow(TObject *Sender) { //FireDAC UniMainModule()->FDQuery1->Active = true; UniMainModule()->FDQuery1->FetchAll(); UniMainModule()->FDQuery1->First(); if(UniMainModule()->FDQuery1->RecordCount == 0) { ShowMessage(L"No data"); return; } UniMainModule()->ClientDataSet1->Active = true; } Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted April 4, 2015 Administrators Share Posted April 4, 2015 Both are valid. FormCreate or FormBeforeShow is preferred over FormShow. Link to comment Share on other sites More sharing options...
Lena Posted April 4, 2015 Author Share Posted April 4, 2015 Thank you very much! Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now