On 11/20/2012 09:11, Eric Kom wrote:
On 20/11/2012 15:20, Luk Vandelaer wrote:
You don't leave the while loop when you found the correct user.
Thanks again Luk,

For each record there will be a showstring call processed.

It should be something like:

var found: boolean;
....
found := false;
while not SQLQueryMySQL.EOF and not found do begin
//Retrieved data fields and assigned to a string variables
retUsername := SQLQueryMySQL.Fields[0].AsString;
retPassword := SQLQueryMySQL.Fields[1].AsString;
found := (getUsername = retUsername) AND
(getPasswordHash = retPassword);
SQLQueryMySQL.Next;
end;
if found then begin
retFullname := SQLQueryMySQL.Fields[2].AsString;
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);
By putting the retFullname := SQLQueryMySQL.Fields[2].AsString; statement after
the SQLQueryMySQL.Next; statement, this last statement makes the field fullname
to jump to the next row, by selecting a wrong fullname for the credentials on
check.

ok... so you only want to jump to the next record if not found, right?


      found := false;
      while not SQLQueryMySQL.EOF and not found do begin
         //Retrieved data fields and assigned to a string variables
         retUsername := SQLQueryMySQL.Fields[0].AsString;
         retPassword := SQLQueryMySQL.Fields[1].AsString;
         found :=  (getUsername = retUsername) AND
            (getPasswordHash = retPassword);
         if not found then SQLQueryMySQL.Next;
        end;
      if found then begin
            retFullname := SQLQueryMySQL.Fields[2].AsString;
            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);

;)

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to