Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

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');
0
T0masz
Asked:
T0masz
  • 2
1 Solution
 
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now