Re: scope of command and garbage collection
- From: "Herfried K. Wagner [MVP]" <hirf-spam-me-here@xxxxxx>
- Date: Wed, 24 May 2006 14:50:44 +0200
"Smokey Grindle" <nospamhere@xxxxxxxxxxxx> schrieb:
Say I have the following piece of code
Dim dtPerson As New DataTable
Dim cmd As New SqlClient.SqlCommand("sp_test", database)
dtPerson.Load(cmd.ExecuteReader)
cmd.dispose()
which instanciates the command object, uses it then destroys it, now if i rewrote it like this
Dim dtPerson As New DataTable
dtPerson.Load(New SqlClient.SqlCommand("test", database)
would that still act the same? because the commands scope is inside the load method, shouldnt it be destroyed after the point of execution has passed the load method?
No, it won't. It will be destoyed by the garbage collector later, but there is no guarantee that it gets destroyed immediately.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
.
- References:
- scope of command and garbage collection
- From: Smokey Grindle
- scope of command and garbage collection
- Prev by Date: Re: Xcopy Install of VB Classic Application
- Next by Date: Re: chrw-2
- Previous by thread: scope of command and garbage collection
- Next by thread: Re: scope of command and garbage collection
- Index(es):
Relevant Pages
|