Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Delphi Databases > delphi 7 & ADOq...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 905 of 986
Post > Topic >>

delphi 7 & ADOquery

by nz039926@[EMAIL PROTECTED] Mar 5, 2006 at 04:59 PM

Hi all,

I am trying to use ADOQuery but program crashes when it tries to
execute this line:
ADOQuery1.Connection := ADOConnection1;
Does anyone know why?

The following code works fine:
procedure TForm1.Button1Click(Sender: TObject);
var
  RS: _RecordSet;
begin
  ADOConnection1.ConnectionString :='Provider=SQLOLEDB.1;Integrated
Security=SSPI;Persist Security Info=False;Data Source=MYSource;Initial
Catalog=MyDB;';
  ADOConnection1.Open;
RS := ADOConnection1.Execute('select * from myTable', cmdText);
end;

but when I try to use ADOQuery like this:
function TForm1.GetDetails: boolean;
var
  MyADOQuery1: TADOQuery;
   ListItem : TListItem;
begin
        MyADOQuery1.Connection := ADOConnection1;{it crashes here}
        ShowMessage('After adding ADOConnection1');
        MyADOQuery1.Close;
        MyADOQuery1.SQL.Clear;
        MyADOQuery1.SQL.Add('select * from myTable');
        MyADOQuery1.SQL.Add('where myField = :bkr');
        ShowMessage(Edit1.Text);
        MyADOQuery1.Parameters.Parambyname('bkr').Value := Edit1.Text;
        MyADOQuery1.Open;
        if (not MyADOQuery1.IsEmpty) then
        begin
          while (not MyADOQuery1.eof) do
          begin
            ListItem := lstArchiveResult.Items.Add;
            ListItem.Caption :=
MyADOQuery1.fieldbyname('myField').AsString;
            MyADOQuery1.Next;
          end;
        end;
        Except on E:Exception do
        begin
          Showmessage('Erreur' + E.Message);
        end;
      end;
  end;
end;

Why is it cra****ng?
Thanks,
Alan.
 




 2 Posts in Topic:
delphi 7 & ADOquery
nz039926@[EMAIL PROTECTED  2006-03-05 16:59:37 
Re: delphi 7 & ADOquery
"Oscar Santiesteban&  2006-03-19 20:58:52 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 0:32:20 CDT 2008.