Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 3 of 3 total |
Why Does Database.LoadRows Return 0 Records? |
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 Tuesday, April 23, 2024 at 08:10 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |