[Lazarus] SQL select problem

Luk Vandelaer luk.vandelaer at wisa.be
Tue Nov 20 14:20:20 CET 2012


You don't leave the while loop when you found the correct user.

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);


Luk




More information about the Lazarus mailing list