| |

VerySource

 Forgot password?
 Register
Search
View: 5|Reply: 3

Novice question, ask for advice! Let's take a look at novices

[Copy link]

1

Threads

2

Posts

3

Credits

Newbie

Rank: 1

Credits
3

 China

Post time: 2020-3-21 18:30:01
| Show all posts |Read mode
procedure Tlogin.OKButtonClick (Sender: TObject);
var
  str1, str2: String;
begin
  if (nameComboBox.Text = '') then
    Showmessage ('Please enter a user ID!')
  else
  begin
    str2: = 'select psw from login where uid =' + nameComboBox.Text + '';
    ADODataSet1.Close;
    ADODataSet1.CommandText: = str2;
    ADODataSet1.Open;
    str1: = VarToStrDef (ADODataSet1 ['psw'], '*'); // Is this assignment wrong? ? ?
    if (pswEdit.Text <> str1) then // Is this wrong? ? ?
      begin
        Showmessage ('Password wrong!' + Str1); // STR1 clearly shows the correct password here
                                          // Why the above is always incorrect
      end
    else
      begin
        Showmessage ('Enter correctly!');
        loged: = true;
        login.Close;
        main.Show;
      end;
  end;
  PswEdit.Text: = '';
end;
Reply

Use magic Report

0

Threads

16

Posts

15

Credits

Newbie

Rank: 1

Credits
15

 China

Post time: 2020-6-29 13:15:01
| Show all posts
Showmessage will be executed when there is a space comparison
Add a trim()
Reply

Use magic Report

1

Threads

2

Posts

3

Credits

Newbie

Rank: 1

Credits
3

 China

 Author| Post time: 2020-6-30 14:00:01
| Show all posts
The problem is to execute Showmessage('wrong password!'+ str1) regardless of whether the input is correct.
For example, pswEdit input is aa and VarToStrDef(ADODataSet1['psw'],'*') also obtains aa, why is it more unequal? ​​Could the trouble be more specific, novice =. =
Reply

Use magic Report

0

Threads

1

Posts

2

Credits

Newbie

Rank: 1

Credits
2

 LAN

Post time: 5 day(s) ago
| Show all posts
trim(pswEdit.Text) <> trim(str1) give it a try
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2020|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list