Good day all,
I got 3 rows in the table login that I used as credentials for authenticate.
the last usernameLogin field in the table as erickom and the first 2 ajm and ajm1.
on the authentication form, when I entered erickom and its password, everything goes well, when I entered an unknown username everything goes well as well like 'Failed to connect using: ' + getUsername; but when I entered the 2 first usernames that are in the table (ajm & ajm1) its not responding as expected, the if condition jump after display the message Retrieving information for: ' + retUsername to Failed to connect using: ' + getUsername. Abnormal behave.
Please view below my code and Thank in advance:
if MySQL55.Connected=True then begin;
//SQLQueryMySQL.SQL.Text := 'SELECT usernameLogin,
passwordLogin, fullNameLogin FROM scholarly.login WHERE usernameLogin =
'':getUsername'' AND passwordLogin = '':getPasswordHash''';
SQLQueryMySQL.SQL.Text := 'SELECT usernameLogin, passwordLogin,
fullNameLogin FROM scholarly.login';
SQLTransactionMySQl.StartTransaction;
SQLQueryMySQL.Open;
while not SQLQueryMySQL.EOF do begin
//Retrieved data fields and assigned to a string variables
retUsername := SQLQueryMySQL.Fields[0].AsString;
retPassword := SQLQueryMySQL.Fields[1].AsString;
retFullname := SQLQueryMySQL.Fields[2].AsString;
if (getUsername = retUsername) AND (getPasswordHash =
retPassword) then begin
ShowString('Retrieving information for: ' + retUsername);
StatusBarLogin.Update;
sleep(2000);
ShowString('Connected to server as: ' + retUsername + ',
known as ' + retFullname);
end
else
ShowString('Failed to connect using: ' + getUsername);
SQLQueryMySQL.Next;
end;
SQLQueryMySQL.Close;
SQLTransactionMySQL.Commit;
end;
except
on D: EDatabaseError do
ShowString('Connection to database as failed, please check your
network.');
end;