The begin
With Table1 do
The begin
The Open;
The SetKey;
FieldValues [' username '] :=Edit1. Text;
If GotoKey then
ShowMessage (' login successful ')
The else
ShowMessage (' login failure);
end;
end;
Why always login fails, the field name is right, edit the content of the input is the username under existing records, I really think impassability,,,
CodePudding user response:
SetKey and GotoKey code didn't stick out, how do you know why the login fails,CodePudding user response:
Suggest use TQuery + SQL statementsCodePudding user response:
I am also a beginner, trim (Edit1. Text) Have a tryCodePudding user response:
The trim is simple to use,CodePudding user response:
Can be, so use TQuery. SQLText='Select count (*) From Table1 where userid=: id and the password=: PWD';TQuery. ParaByname (' : id) :=id
TQuery. ParaByname (' : ipwd) :=password
Use parameterized queries, avoid SQL injection
Direct judgment to return the result at the same time, avoid frequent database queries,
CodePudding user response:
To determine the table to open?CodePudding user response:
You single-step tracking GotoKey inside the code to understand why,