![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 3 of 3 total |
![]() |
Tue, Jul 4 2017 11:16 AM | Permanent Link |
Frederick Chin | I see that EWB 2.06b2 now have the TDatabase component and it avoids having TDatasets cluttering the forms.
However, I am a loss as to what I am doing wrong to get no records for the following steps:- 1. In the Database Manager, create the database (connection is OK) and the dataset (query: select * from table and preview OK) 2. Dragged the database into the Project Manager to create a TDatabase unit. Named the database dbaData. 3. The database unit is auto-created for the project. 4. In the OnClick event of a button placed in a form, typed the following code:- procedure TfrmMain.Button1Click(Sender: TObject); var oQry : TDataset; begin oQry:=dbaData.qMnpsmain; dbaData.Loadrows(oQry); lblStatus.Caption:='Rows: '+IntToStr(oQry.RowCount); end; 5. The oQry.Rowcount always returns 0. What am I missing? -- Frederick |
Tue, Jul 4 2017 12:14 PM | Permanent Link |
Uli Becker | Frederick,
> procedure TfrmMain.Button1Click(Sender: TObject); > var > oQry : TDataset; > begin > oQry:=dbaData.qMnpsmain; > dbaData.Loadrows(oQry); > lblStatus.Caption:='Rows: '+IntToStr(oQry.RowCount); > end; > > 5. The oQry.Rowcount always returns 0. > > What am I missing? Due to the asynchronous behavior of JS the lblStatus.Caption line will be executed *before* the data has been loaded. That's why you have to place this line: lblStatus.Caption:='Rows: '+IntToStr(oQry.RowCount); in the AfterLoad event of dbaData and you'll see the correct RowCount. Uli |
Wed, Jul 5 2017 12:55 AM | Permanent Link |
Frederick Chin | Uli,
/* Due to the asynchronous behavior of JS the lblStatus.Caption line will be executed *before* the data has been loaded. That's why you have to place this line: lblStatus.Caption:='Rows: '+IntToStr(oQry.RowCount); in the AfterLoad event of dbaData and you'll see the correct RowCount. */ Thanks. I am obviously not using EWB enough to remember this. ![]() -- Frederick |
This web page was last updated on Friday, March 17, 2023 at 10:08 PM | Privacy Policy![]() © 2023 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |