BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

delphi 7 ADOQuery

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Alan
Guest





PostPosted: Mon Mar 06, 2006 1:03 am    Post subject: delphi 7 ADOQuery Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.