 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Alan Guest
|
Posted: Mon Mar 06, 2006 1:03 am Post subject: delphi 7 ADOQuery |
|
|
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.GetDetailsOfBkno: 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 crashing?
Thanks,
Alan. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|