Avatar of ST3VO
ST3VO
Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

SQL Query assistance needed - Populate var with Query result

Hi experts,

I'm a bit stuck here.

I want to look for a the company name of an accountID

So I thought I'd do a query.

See code:

The problem is that I wanted to assign the result to a variable (opened to suggestions here).

So, I can then assign the result to a Label.caption.

I really don't know how to do this.

Could someone help please?

Thanks

ST3VO

Try
       CompName:=(memo2.Text);
       adoquery1.active := false;
       adoquery1.SQL.Add('select CompanyName from motors where AccountID = "' +(CompName)+'"');
       adoquery1.Active := true;
 
      finally
        CompName:= ADOQuery1;
        Label1.Caption:=('CompName');
        ADOQuery1.active := false;
        ADOQuery1.Close;
        ADOQuery1.SQL.Clear;
      end;
       end;

Open in new window

Delphi

Avatar of undefined
Last Comment
ST3VO

8/22/2022 - Mon