Article View: borland.public.cppbuilder.database.ado
Article #714Re: Problem on memory leak with TADOQuery
From: pieter
Date: Tue, 26 Jul 2005 15:02
Date: Tue, 26 Jul 2005 15:02
84 lines
2844 bytes
2844 bytes
Here is a way:
Create a Connection class (Connection.cpp) with a TADOQuery and a method like (not tested):
Connection :: Connection ()
{
//set your connection string here.
ADOQuery1->ConnectioString = ...
//Or you can set the connection string in de object inspector
}
TADOQuery *Connection :: open(String stmtSQL)
{
try {
ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery->SQL->Add(stmtSQL);
ADOQuery1->Open();
} catch (Exception &e) {
ShowMessage (e.Message);
}
return ADOQuery1;
}
you can call this class by:
//include header
#include "Connection.h"
TADOQuery *qry = new TADOQuery(Application);
Connection *con = new Connection();
String SQL = "SELECT * FROM myTable"
qry = con->open(SQL);
//do something with the query;
//delete adoquery en connection
delete qry;
delete con;
Good luck.
"Sara T." <sarana@thaiquest.com> wrote:
>I'm using an simple ADOQuery with:
>AdoQuery1.Close;
>AdoQuery1.Sql.Clear;
>AdoQuery1.SQL.Add('select * from myTable');
>AdoQuery1.Open;
>
>Every call I lose memory.
>
>I found the same question in Google but nobody answers.
>
>Sara T.
>
>"Pieter" <Pieter@nomail.com> wrote in message
>news:42e62634$1@newsgroups.borland.com...
>>
>> It would be easier to tell something if you post some code.
>> Pieter
>>
>> "Sara T." <sarana@thaiquest.com> wrote:
>>>Does anybody find this?
>>>
>>>I have something to create and destroy this object (TADOQuery) a lot of
>>>times, I found TADOQuery does not release the memory and eats memory until
>>>the machine becomes out of memory.
>>>
>>>I thought the several people found this problem (I search in the google)
>>>but
>>>nobody answer.
>>>
>>>Again, it anybody finds the solutions, lindy post it.
>>>
>>>Sara T.
>>>
>>>
>>
>
>
Technical Details
Message-ID:
<42e65079$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsgate.cistron.nl!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!newsfeeder.wxs.nl!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<42e4d1b3$1@newsgroups.borland.com> <42e62634$1@newsgroups.borland.com> <42e64264$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,5b03d9688e33bc12 X-Google-Attributes: gid10698b,public X-Google-Language: ENGLISH,ASCII-7-bit From: "pieter" <pieter@nomail.com> Sender: "pieter" <pieter@nomail.com> Reply-To: "pieter" <pieter@nomail.com> Subject: Re: Problem on memory leak with TADOQuery Newsgroups: borland.public.cppbuilder.database.ado X-User-Info: 193.173.66.209 X-Forwarded-For: 172.21.155.55, 172.21.0.161 References: <42e4d1b3$1@newsgroups.borland.com> <42e62634$1@newsgroups.borland.com> <42e64264$1@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <42e65079$1@newsgroups.borland.com> Date: 26 Jul 2005 08:02:17 -0700 X-Trace: newsgroups.borland.com 1122390137 207.105.83.66 (26 Jul 2005 08:02:17 -0700) Lines: 85 Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsgate.cistron.nl!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!newsfeeder.wxs.nl!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail