Lena Posted April 4, 2015 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; } Quote
Administrators Farshad Mohajeri Posted April 4, 2015 Administrators Posted April 4, 2015 Both are valid. FormCreate or FormBeforeShow is preferred over FormShow. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.