dudey
dudey

Reputation: 97

Delphi database search

I'm working on a small app with login by mail/password which uses a database. In this database, the following are stored:

For login I check user mail/password in DB with this code:

if not (tbl1.Locate('Mail', edt1.text,[]) and tbl1.Locate('Password', edt2.text,[]) ) then
   begin
    mmo1.lines.add('Not Registered User');
   end
   else
   begin
    mmo1.lines.add('Registered User');
   end;
end;

This works for login. My problem is with credits. For example user John has 10 credits.

I cannot use locate here

How can I get the available amount of credits of John from the database?

Upvotes: 1

Views: 3857

Answers (1)

Ravaut123
Ravaut123

Reputation: 2818

Use multiple fields in the locate: see Using locate

if  (tbl1.Locate('Mail; Password', VarArrayOf([edt1.text, edt2.text]),[])) then 
begin
  mmo1.lines.add('Registered User: '+ tbl1.FieldByName('credits').asString);
end
else
begin
  mmo1.lines.add('Not Registered User');
end;

Upvotes: 5

Related Questions