Re: How to clear controls from a form - Help Needed
- From: Siv <Siv@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 10 Aug 2008 10:44:00 -0700
Jack,
This is where my VB6 roots probably show. I always treat = (equals) as
meaning copy from the right side to the left side. From what you have just
said that isn't the case, in this instance I am making my variable on the
left side actually equal to rather than assigning.
Now I understand that, I can see that if I dispose (or destruct if you
believe what Cor says), the variable on the left side of the argument, I am
also disposing the original one as they are one and the same object.
That actually makes me a lot happier. Also knowing that as soon as I exit
the black box function that reference is removed helps. I feel a lot tidier
knowing that.
Thanks for you help.
Siv
--
Martley, Near Worcester, UK
"Jack Jackson" wrote:
On Thu, 7 Aug 2008 12:52:01 -0700, Siv <Siv@xxxxxxxxxxxxxxxxxxxxxxxxx>.
wrote:
Jack,
I am pleased to report that in pretty much ebery instance the calling
routine will have something like this:
Dim CallersDR as sqlDataReader=nothing
try
CallersDR = GetData(SomeID)
...
various code that uses the CallersDR.
...
Catch ex as exception
Error handler code
Finally
if not isnothing(CallersDR) then
CallersDR.Close()
End If
End Try
So if I read teh conversations correctly, the line:
CallersDR.Close()
Will not only close the CallersDR but will also close the Dr that is in the
black box routine (GetData(ID)) as well? This is the concept that I didn't
follow and what was worrying me because in my mind I see the Dr used in the
GetData as being a separate object to the one in the above calling routine.
So therefore I have been worrying that this was being left undisposed.
Am I right in surmising from what has been said above that the Dr in GetData
and teh CallersDR in my calling routine are both referencing the same
DataReader object from the moment that the GetData routine returns the Dr it
has to the caller??
If this is correct I will be a happy man as this has clarified something I
have not understood properly.
Siv
There is no "Dr that is in the black box routine (GetData(ID)) as
well". There is only one SqlDataReader. The black box method creates
it and returns a reference to it. The reference that the black box
method holds to the object goes away once the method exits, leaving
only the caller's reference.
It's like this:
Dim dr As New SqlDataReader
Dim dr1 As SqlDataReader = dr
Dim dr2 As SqlDataReader = dr
There is only one object with three references to that object: dr, dr1
and dr2.
- Follow-Ups:
- Re: How to clear controls from a form - Help Needed
- From: Jack Jackson
- Re: How to clear controls from a form - Help Needed
- References:
- Re: How to clear controls from a form - Help Needed
- From: Stephany Young
- Re: How to clear controls from a form - Help Needed
- From: Siv
- Re: How to clear controls from a form - Help Needed
- From: Stephany Young
- Re: How to clear controls from a form - Help Needed
- From: Siv
- Re: How to clear controls from a form - Help Needed
- From: Cor Ligthert[MVP]
- Re: How to clear controls from a form - Help Needed
- From: Jack Jackson
- Re: How to clear controls from a form - Help Needed
- From: Cor Ligthert [MVP]
- Re: How to clear controls from a form - Help Needed
- From: Siv
- Re: How to clear controls from a form - Help Needed
- From: Jack Jackson
- Re: How to clear controls from a form - Help Needed
- From: Siv
- Re: How to clear controls from a form - Help Needed
- From: Jack Jackson
- Re: How to clear controls from a form - Help Needed
- From: Siv
- Re: How to clear controls from a form - Help Needed
- From: Jack Jackson
- Re: How to clear controls from a form - Help Needed
- Prev by Date: Help with C# class to VB.net conversion.
- Next by Date: Re: Missing DAO licence on target PC
- Previous by thread: Re: How to clear controls from a form - Help Needed
- Next by thread: Re: How to clear controls from a form - Help Needed
- Index(es):
Relevant Pages
|
Loading