Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 6 of 6 total |
dataset params - what's wrong |
Sun, Jun 16 2013 6:56 PM | Permanent Link |
Stephen Barker | Hi,
I'm struggling with this seemingly simple query to check the login and password for a user: procedure TfrmLogin.btnLoginClick(Sender: TObject); begin qUser.Close; qUser.Params.Clear; qUser.Params.Add('Login='''+edUserName.Text+''''); Database.Load(qUser); if qUser.RowCount = 0 then begin ShowMessage('This User Name was not found'); exit; end; if qUser.Columns['Password'].asString <> edPassword.Text then begin ShowMessage('The Password is incorrect'); exit; end; ModalResult := mrOK; end; The RowCount is always zero. Yet when I try the same thing in the DataSet Manager Preview tab it works fine. select * from user where Login={Login='steve'} How do I go about debugging this? |
Sun, Jun 16 2013 7:13 PM | Permanent Link |
Stephen Barker | Further info:
These events: function TfrmLogin.qUserBeforeLoad(Sender: TObject): Boolean; begin ShowMessage('before load: '+qUser.Params.Text); result := true; end; procedure TfrmLogin.qUserAfterLoad(Sender: TObject); begin ShowMessage('after load: '+IntToStr(qUser.RowCount)); end; procedure TfrmLogin.qUserAfterOpen(Sender: TObject); begin ShowMessage('after open: '+IntToStr(qUser.RowCount)); end; They are displayed (in the wrong order) as follows: after load: 1 before load: Login='steve' after open: 0 So what can be happening to the dataset between loading and opening? And why do these events fire in this order? thanks, Steve |
Mon, Jun 17 2013 2:45 AM | Permanent Link |
Matthew Jones | I wonder if you are giving time for the query to finish? Most of EWB is
async, so you have to wait for the query to happen before you can test the result. This is normally done on a completion callback, -- Matthew Jones |
Mon, Jun 17 2013 4:25 AM | Permanent Link |
Uli Becker | Stephen,
> > The RowCount is always zero. Yet when I try the same thing in the DataSet Manager Preview tab it works fine. > select * from user where Login={Login='steve'} As Matthew indicated most things are asynchronous and you have to use the AfterLoad event to get the number of rows of your dataset. Uli |
Mon, Jun 17 2013 6:24 AM | Permanent Link |
Stephen Barker | Thanks guys. You are correct.
I've moved the rest of that code into the after load event - all good now. |
Tue, Jun 18 2013 1:24 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Stephen,
<< They are displayed (in the wrong order) as follows: >> I see you already know that you need to use AfterLoad. As for the display order - the ShowMessage calls are "stacked" due to them also being asynchronous, meaning that you're going to see the last call first, followed by the second-to-last, etc. Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Friday, November 1, 2024 at 07:01 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |