Article View: borland.public.cppbuilder.database.ado
Article #4993ADO Query Problem
From: Robert Lancaster
Date: Fri, 17 Aug 2001 08:58
Date: Fri, 17 Aug 2001 08:58
47 lines
2086 bytes
2086 bytes
Greetings,
I am using MS SQL Server 2000. I have the following method in my data module
for processing generic queries:
TADOQuery* __fastcall TdmUserManager::GetQuery(String QueryText)
{
TADOQuery* Query = new TADOQuery(this);
Query->Connection = cnctnDB;
Query->SQL->Text = QueryText;
Query->Open();
return Query;
}
I use it like so to populate a TListView:
void __fastcall TfrmUserManagerMain::LoadUsers()
{
TListItem *ListItem;
lstvwUsers->Items->BeginUpdate();
lstvwUsers->Items->Clear();
TADOQuery* Q = dmUserManager->GetQuery(
"SELECT a.name as UserName, b.name as GroupName"\
" FROM sysusers a"\
" LEFT OUTER JOIN sysusers b ON a.gid = b.gid"\
" WHERE ((a.uid <> a.gid) and (a.uid > 1)) and (b.uid = b.gid)"\
" ORDER BY a.Name" );
while ( ! Q->Eof )
{
ListItem = lstvwUsers->Items->Add();
ListItem->Caption = Q->FieldByName("UserName")->AsString;
ListItem->SubItems->Add(Q->FieldByName("GroupName")->AsString);
Q->Next();
}
delete Q;
lstvwUsers->Items->EndUpdate();
}
For some or other obscure reason whenever it hits the line "delete Q" the
system throws the exception depicted in the attached image file. Please can
someone help me ?
Thanks,
Robert Lancaster
Technical Details
Message-ID:
<3b7cdc83_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!isdnet!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!dnewsShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,cc9d2de0d065fd53,start X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2001-08-17 02:10:19 PST From: "Robert Lancaster" <LancasterR@resa.co.za> Newsgroups: borland.public.cppbuilder.database.ado Subject: ADO Query Problem Date: Fri, 17 Aug 2001 10:58:13 +0200 Lines: 52 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 NNTP-Posting-Host: 168.209.21.126 Message-ID: <3b7cdc83_1@dnews> X-Trace: dnews 998038659 168.209.21.126 (17 Aug 2001 01:57:39 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!isdnet!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!dnews