|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Command.Close vs Command.DisposeHello All:
Can anyone tell me what the difference is between the Close method of the OleDbCommand object and the Dispose method of the OleDbCommand object? TIA, -- Joe VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation Joe wrote:
> Hello All: Dispose releases all the resources used by the object. Close just > > Can anyone tell me what the difference is between the Close method of the > OleDbCommand object and the Dispose method of the OleDbCommand object? > > TIA, releases the underlining connection so it can be used again for something else. Chris Chris wrote:
Show quoteHide quote > Joe wrote: Um... On second though, the OleDbCommand object doesn't have a Close > >> Hello All: >> >> Can anyone tell me what the difference is between the Close method of >> the OleDbCommand object and the Dispose method of the OleDbCommand >> object? >> >> TIA, > > > Dispose releases all the resources used by the object. Close just > releases the underlining connection so it can be used again for > something else. > > Chris method. My comments would be correct for a OleDbDataReader object though. Chris Thanks Chris. My question wasn't accurate, but you answered the spirit of it
anyway. -- Show quoteHide quoteJoe VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation "Chris" wrote: > Chris wrote: > > Joe wrote: > > > >> Hello All: > >> > >> Can anyone tell me what the difference is between the Close method of > >> the OleDbCommand object and the Dispose method of the OleDbCommand > >> object? > >> > >> TIA, > > > > > > Dispose releases all the resources used by the object. Close just > > releases the underlining connection so it can be used again for > > something else. > > > > Chris > > Um... On second though, the OleDbCommand object doesn't have a Close > method. My comments would be correct for a OleDbDataReader object though. > > Chris > About dispose :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemidisposableclassdisposetopic.asp if a object contains a shutdown feature like close you must always explicitly call it if you are finished with it however if a component implements an idisposible interface you may call it but it is not absolutely necesary as the GC wil call it for you I use the following rule for good coding practice , for method level scoped objects i never call a dispose method , however after the usage of a global object ( global to the class ) that implements idisposible i do call it p.s. calling dispose multiple times will only result in coding overhead , and a bigger executable in the end :-) , it does not hurt the performance as idisposible has a boolean flag if it is / was called before on the current object regards Michel Posseth [MCP] Show quoteHide quote "Joe" <joeherro@donotspam.yahoo.com> schreef in bericht news:9065E52C-D80E-4A4C-9460-55612F213995@microsoft.com... > Hello All: > > Can anyone tell me what the difference is between the Close method of the > OleDbCommand object and the Dispose method of the OleDbCommand object? > > TIA, > -- > Joe > > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation Are you saying that you have to close a form before disposing of it? I use
form.dispose when I'm thru with the form and don't bother with the form.close method unless I want to show the form again. Will I have a problem doing this? -- Show quoteHide quoteDennis in Houston "m.posseth" wrote: > > About dispose : > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemidisposableclassdisposetopic.asp > > if a object contains a shutdown feature like close you must always > explicitly call it if you are finished with it > > however if a component implements an idisposible interface you may call it > but it is not absolutely necesary as the GC wil call it for you > > > I use the following rule for good coding practice , for method level scoped > objects i never call a dispose method , however after the usage of a global > object ( global to the class ) that implements idisposible i do call it > > > p.s. > calling dispose multiple times will only result in coding overhead , and a > bigger executable in the end :-) , it does not hurt the performance as > idisposible has a boolean flag if it is / was called before on the current > object > > regards > > Michel Posseth [MCP] > > > > > "Joe" <joeherro@donotspam.yahoo.com> schreef in bericht > news:9065E52C-D80E-4A4C-9460-55612F213995@microsoft.com... > > Hello All: > > > > Can anyone tell me what the difference is between the Close method of the > > OleDbCommand object and the Dispose method of the OleDbCommand object? > > > > TIA, > > -- > > Joe > > > > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation > > > Dennis,
Just do it as Michel says, where however the modal form is on of the exceptions which you have to dispose. Howerver closing something end than disposing it is AFAIK stupid. Cor
The old Structure/Class Argument
Migrating From ListBox to ListView: Only One Problem DATE HELLLPPPP RTF How to make Windows inaccessible from my software user? Referencing Datagrid Information ClickOnce Deployment questions newbie question vb.net bits BindingSource for a class - need a light bulb moment Change the write path for My.Application.Log.WriteEntry? |
|||||||||||||||||||||||