I have this code that I use on a login screen, which when the user uses the correct password, it directs to the main screen, so everything okay, it works perfectly, but when I fecho
the application it displays a message of the code.
Invalid user name or password. If you have forgotten your password, consult your system administrator
procedure TFrmLogin.imgLoginClick(Sender: TObject);
var StrSqlLog, mensagem: String;
begin
sleep(500);
strSqlLog:= 'select u.*, p.* '+
'from usuario u inner join perfil p '+
'on u.nivel = p.id '+
'where u.nome = '+#39+
edtName.Text+
#39 + ' and u.senha = ' +
#39 + edtPass.Text + #39;
FrmHome.QueryLogin.Close;
FrmHome.QueryLogin.SQL.Clear;
FrmHome.QueryLogin.SQL.Add(strSqlLog);
FrmHome.QueryLogin.Open();
if FrmHome.QueryLogin.RecordCount = 1 then
begin
FreeAndNil(FrmLogin);
Application.CreateForm(TFrmhome, Frmhome);
Application.Run;
end;
if FrmHome.QueryLogin.RecordCount = 0 then
begin
mensagem:= 'Nome ou senha do usuário '+
'inválidos.' + #13 + #13 +
'Se você esqueceu sua '+
'senha, consulte ' + #13 +
'o administrador do sistema.';
Application.MessageBox(PChar
(mensagem),
'Login não autorizado',
MB_OK+MB_IconError);
edtName.Clear;
edtPass.Clear;
edtName.SetFocus;
end;