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 

Is this correct? (TADOConnection)

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO)
View previous topic :: View next topic  
Author Message
Frederico Pissarra
Guest





PostPosted: Sat Oct 21, 2006 12:59 am    Post subject: Is this correct? (TADOConnection) Reply with quote



Hello!!!

Taking a look at ADODB unit in $(DELPHI)\Source\VCL (I'm using D7 here), you
can see the following code:

-------------%<------------cut here -------------%<------------------------
destructor TADOConnection.Destroy;
begin
Destroying;
Close;
ClearRefs;
FreeAndNil(FCommands);
if FConnEventsID > 0 then
OleCheck(ConnectionPoint.UnAdvise(FConnEventsID));
FConnEventsID := 0;
FConnectionObject := nil;
inherited Destroy;
end;

-------------%<------------cut here -------------%<------------------------

Notice that FConnectionObject is not released (calling IUnknown.Release),
but the reference simply will point to nil.

Is this correct?

[]s
Fred
Back to top
Guest






PostPosted: Sat Oct 21, 2006 2:24 am    Post subject: Re: Is this correct? (TADOConnection) Reply with quote



Not sure what you are asking, the code is from the unit ADODB. Are you
wondering if your connection/object is free at this point?
Frederico Pissarra wrote:
Quote:
Hello!!!

Taking a look at ADODB unit in $(DELPHI)\Source\VCL (I'm using D7 here), you
can see the following code:

-------------%<------------cut here -------------%<------------------------
destructor TADOConnection.Destroy;
begin
Destroying;
Close;
ClearRefs;
FreeAndNil(FCommands);
if FConnEventsID > 0 then
OleCheck(ConnectionPoint.UnAdvise(FConnEventsID));
FConnEventsID := 0;
FConnectionObject := nil;
inherited Destroy;
end;

-------------%<------------cut here -------------%<------------------------

Notice that FConnectionObject is not released (calling IUnknown.Release),
but the reference simply will point to nil.

Is this correct?

[]s
Fred
Back to top
Bill Dekleris
Guest





PostPosted: Sat Oct 21, 2006 8:11 am    Post subject: Re: Is this correct? (TADOConnection) Reply with quote



Frederico,

if you take a look at FConnectionObject's declaration, you'l see that it
is a "pointer" to an interface (ADOInt._Connection) that descends from
IInterface, and as such it is reference counted. So, when you assign nil
to this pointer, the underlying object is freed. So, yes, the command is
correct.

Bill Dekleris

Quasar Software.

--
-----------------------------------------------------------------------------------------


http://www.infosnap.eu

Home page of InfoSnap - the powerful, all-purpose information and
knowledge-base manager.

-----------------------------------------------------------------------------------------



Frederico Pissarra wrote:
Quote:
Hello!!!

Taking a look at ADODB unit in $(DELPHI)\Source\VCL (I'm using D7 here), you
can see the following code:

-------------%<------------cut here -------------%<------------------------
destructor TADOConnection.Destroy;
...
FConnectionObject := nil;
...
end;

-------------%<------------cut here -------------%<------------------------

Notice that FConnectionObject is not released (calling IUnknown.Release),
but the reference simply will point to nil.

Is this correct?

[]s
Fred

Back to top
Frederico Pissarra
Guest





PostPosted: Mon Oct 23, 2006 6:40 pm    Post subject: Re: Is this correct? (TADOConnection) Reply with quote

<danielk1 (AT) wi (DOT) rr.com> escreveu na mensagem
news:1161379473.609229.42860 (AT) e3g2000cwe (DOT) googlegroups.com...
Quote:
Not sure what you are asking, the code is from the unit ADODB. Are you
wondering if your connection/object is free at this point?

Precisely.... Notice that connection object is created in the constructor in
CreateADOObject() function - wich calls CoCreateInstance with the proper
CLSID.
CoCreateInstance will call AddRef() IUnknown's member, but at the destructor
FConnectionObject is simply set to nil without calling Release()!

This means any connection object will remain in memory until the processes
dies... or am I wrong?

[]s
Fred


Quote:
Frederico Pissarra wrote:
Hello!!!

Taking a look at ADODB unit in $(DELPHI)\Source\VCL (I'm using D7 here),
you
can see the following code:

-------------%<------------cut
here -------------%<------------------------
destructor TADOConnection.Destroy;
begin
Destroying;
Close;
ClearRefs;
FreeAndNil(FCommands);
if FConnEventsID > 0 then
OleCheck(ConnectionPoint.UnAdvise(FConnEventsID));
FConnEventsID := 0;
FConnectionObject := nil;
inherited Destroy;
end;

-------------%<------------cut
here -------------%<------------------------

Notice that FConnectionObject is not released (calling IUnknown.Release),
but the reference simply will point to nil.

Is this correct?

[]s
Fred
Back to top
Frederico Pissarra
Guest





PostPosted: Mon Oct 23, 2006 6:41 pm    Post subject: Re: Is this correct? (TADOConnection) Reply with quote

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO) 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.