[Lazarus] SQL select problem
Reinier Olislagers
reinierolislagers at gmail.com
Tue Nov 20 19:36:58 CET 2012
On 20-11-2012 13:47, Eric Kom wrote:
> Please view below my code and Thank in advance:
>
I'd do something like the following (untested):
var
LoginSuccess: boolean;
....
LoginSuccess:=false;
if MySQL55.Connected=True then
try
SQLQueryMySQL.SQL.Text := 'SELECT fullNameLogin FROM scholarly.login '+
'WHERE usernameLogin = :getUsername AND passwordLogin =
:getPasswordHash';
SQLQueryMySQL.ParamByName('getUsername').AsString:=getUsername;
SQLQueryMySQL.ParamByName('getPasswordHash').AsString:=getPasswordHash;
SQLTransactionMySQl.StartTransaction;
SQLQueryMySQL.Open;
if not SQLQueryMySQL.EOF then
begin
LoginSuccess := true;
retFullname := SQLQueryMySQL.Fields[2].AsString;
ShowString('Retrieving information for: ' + getUsername);
StatusBarLogin.Update;
sleep(2000);
ShowString('Connected to server as: ' + getUsername + ', known as
' + retFullname);
end
else
begin
ShowString('Failed to connect using: ' + getUsername);
end;
SQLQueryMySQL.Close;
SQLTransactionMySQL.Commit;
except
on D: EDatabaseError do
ShowString('Connection to database as '+getUsername+' failed, please
check your network.');
end;
//now use LoginSuccess to see if user could log in etc
More information about the Lazarus
mailing list