In theory, since SqlCommand implements IDisposable, the SqlCommand object should always be deleted. I personally wrap the expression of use around myself. However, I see a lot of code that never disposes of SqlCommand objects without any obvious problems.
I understand that finalizers will ultimately be caused by garbage collection, but since in most cases this can take quite a while (and never in others), why doesnβt the code crash due to the expiration of some resource?
In our own code base, we have code that runs 24x7 without utilization of commands. I would like to clean it, but it is hard to justify when it does not cause any problems.
Kevin gale
source share