| |

VerySource

 Forgot password?
 Register
Search
View: 973|Reply: 8

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

[Copy link]

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 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

17

Posts

16.00

Credits

Newbie

Rank: 1

Credits
16.00

 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

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 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.00

Credits

Newbie

Rank: 1

Credits
2.00

 LAN

Post time: 2020-7-5 17:30:01
| Show all posts
trim(pswEdit.Text) <> trim(str1) give it a try
Reply

Use magic Report

1

Threads

13

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-7-16 13:30:01
| Show all posts
Show the length of both strings to see if there are hidden characters.
Reply

Use magic Report

0

Threads

25

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 China

Post time: 2020-7-16 14:30:02
| Show all posts
Try it like this

...
  if UpperCase(pswEdit.Text) <> UpperCase(str1) then

...
Reply

Use magic Report

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-7-16 16:45:01
| Show all posts
Wow, there are so many kind people, anyway, thank you first~~~
Reply

Use magic Report

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-7-16 20:15:01
| Show all posts
suppermanYou are right, thank you
but

function UpperCase(const S: string): string;
var
  Ch: Char;
  L: Integer;
  Source, Dest: PChar;
begin
  L := Length(S);
  SetLength(Result, L);
  Source := Pointer(S);
  Dest := Pointer(Result);
  while L <> 0 do
  begin
    Ch := Source^;
    if (Ch >='a') and (Ch <='z') then Dec(Ch, 32);
    Dest^ := Ch;
    Inc(Source);
    Inc(Dest);
    Dec(L);
  end;
end;

I don't understand. . . . Could you please give me some pointers? =
Reply

Use magic Report

0

Threads

3

Posts

252.00

Credits

Full Member

Rank: 3Rank: 3

Credits
252.00

 China

Post time: 2020-7-18 14:14:04
| Show all posts
Prompt you what is wrong~~
Reply

Use magic Report

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

Points Rules

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

Quick Reply To Top Return to the list