We help IT Professionals succeed at work.
Get Started

SQL Query assistance needed - Populate var with Query result

ST3VO
ST3VO asked
on
264 Views
Last Modified: 2013-11-23
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

Comment
Watch Question
Top Expert 2007
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE