troubleshooting Question

SQL Query assistance needed - Populate var with Query result

Avatar of ST3VO
ST3VOFlag for United Kingdom of Great Britain and Northern Ireland asked on
Delphi
3 Comments1 Solution265 ViewsLast Modified:
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

ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros