weird adoquery behavior

Alright so the problem is that I have a onevent function that executes and after Memo.Lines.Add starting query the function just quits and none of the other functions below that execute now if i take out the ADOQuery functions it works fine... Whats wrong with it? Basicly Im looking to just lookup an person_id by quering a table by the phone number.
It will only return one record...

Any advice would be great
Tom

       Memo.Lines.Add('starting query');
        ADOQuery1.SQL.Clear;
        ADOQuery1.SQL.Text:='select * from linkcallperson where phone_number = ' + QuotedStr(Trim(number));
        Memo.Lines.Add(inttostr(ADOQuery1.ExecSQL));
        ADOQuery1.ExecSQL;

        if not VarIsNull(ADOQuery1.FieldValues['person_id']) then
          person_id := String(ADOQuery1.FieldValues['person_id'])
        else
          person_id := '';
        Memo.Lines.Add('ifquery');
T0maszAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mohammed NasmanSoftware DeveloperCommented:
Hello

  Use Open method to execute select statmenet, use ExecSql  when you need to execute sql statement that doesn't return records such as (insert, update, delete)


Regards,
Mohammed
0
esoftbgCommented:
      Memo.Lines.Add('starting query');
       ADOQuery1.SQL.Clear;
       ADOQuery1.SQL.Text:='select * from linkcallperson where phone_number = ' + QuotedStr(Trim(number));
       Memo.Lines.Add(inttostr(ADOQuery1.Active := True));
       ADOQuery1.Active := True;

       if not VarIsNull(ADOQuery1.FieldValues['person_id']) then
          person_id := String(ADOQuery1.FieldValues['person_id'])
        else
          person_id := '';
        Memo.Lines.Add('ifquery');
0
esoftbgCommented:
The best is:
      Memo.Lines.Add('deactivating query');
      ADOQuery1.SQL.Active := False;
      ADOQuery1.SQL.Text:='select * from linkcallperson where phone_number = ' + QuotedStr(Trim(number));
      Memo.Lines.Add('activating query');
      ADOQuery1.Active := True;
      if not VarIsNull(ADOQuery1.FieldValues['person_id']) then
        person_id := String(ADOQuery1.FieldValues['person_id'])
      else
        person_id := '';
      Memo.Lines.Add('if query');
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.