I am new to Delphi and noticed that there is no presence of use of variables like date readers
in this language as in VB. I am making a procedure
to login to the system. The connection to the bank is already ready and functional my doubt is:
How to proceed with reading data in the database now?
Follow the code with the connection to the bank:
procedure TFrmPrincipal.GetConnection();
var
diretorioDb: String;
begin
diretorioDb := ExtractFilePath(ParamStr(0));
if FileExists(diretorioDb + 'DataBase.mdb') then
begin
if dmDados.bdConnection.Connected = false then
begin
dmDados.bdConnection.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Psddword="";Data Source=' + diretorioDb + 'DataBase.mdbde Seu programa';
dbDados.bdConnection.Connected := true;
end
else
begin
dmDados.bdConnection.Connected := false;
end;
end
else
begin
ShowMessage('Banco de Dados não Encontrado!');
end;
end;
Login method:
procedure TfrmLogin.LogarSistema(userPr: string; senhaPr: string);
begin
with dmDados.query do
begin
Close;
SQL.Clear;
SQL.Add('SELECT * FROM usuarios WHERE username =userPr and senha =senhaPr');
Parameters.ParamByName('userPr').Value := userPr;
Parameters.ParamByName('senhaPr').Value := senhaPr;
ExecSQL;
end;
showmessage('Logado Com Sucesso!');
end;