Events used for login window in power builder 10.0

379 views Asked by At

I have a login window for entering into my application, here I inserted a table named login1 and have two columns as "username" and "password" . I included the events for make "logging in" bye two cases 1) a command button 2) Enter key. So I Used to write these following code in button cliked event and a user event that trigger the keydown of "Enter!" key.

if KeyDown(KeyEnter!) THEN   //In User Event case only
string ls_unm;
string ls_pass,ls_field;
ls_unm=dw_log.GetItemString(1,"user_name1");
ls_pass=dw_log.GetItemString(1,"password1");
select password1 into :ls_field  from login1 where login1.user_name1=:ls_unm;
if(ls_field=ls_pass) then  
commit; 
close (w_login);
open(w_main);
else
 rollback;
 messagebox( "","login faild");
 dw_log.Reset();
 dw_log.InsertRow(0);
 end if
    END if

but I got always "login faild" response even I checked through it by debug mode how I make the proper login with this

2

There are 2 answers

0
Eduardo G. On

You may be missing the "AcceptText" line?

if KeyDown(KeyEnter!) THEN   //In User Event case only
    string ls_unm;
    string ls_pass,ls_field;
    dw_log.AcceptText()
    ls_unm=dw_log.GetItemString(1,"user_name1");
    ls_pass=dw_log.GetItemString(1,"password1");
2
Arfath On

I second Edurado about the AcceptText().

Use if dw_log.accepttext() <> 1 then return, to handle any data validation failures.

Secondly, Command buttons have a Default property which will trigger the clicked event when user presses enter key. You need not use separate events for both. Just a humble opinion.