Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

closing db

Whats the difference between
System.Data.CommandBehavior.CloseConnection
and
.Close()
[112 byte] By [syedwna] at [2007-11-11 10:28:16]
# 1 Re: closing db
System.Data.CommandBehavior.CloseConnection is an enumeration (http://aspnet.4guysfromrolla.com/articles/042804-1.aspx), .Close is a method. You pass System.Data.CommandBehavior.CloseConnection as a parameter to the ExecuteReader method of a Command object to instruct it to automatically close the connection after it has retrieved all the data. You call the .Close method on an object to explicitly close it.
Phil Weber at 2007-11-11 23:11:48 >
# 2 Re: closing db
ok but my questions was

using "System.Data.CommandBehavior.CloseConnection " is their is any drop in performance.Is it true
syedwna at 2007-11-11 23:12:54 >
# 3 Re: closing db
I don't think having the Command object close the connection automatically performs any worse than your doing it manually. Did someone tell you that it does?
Phil Weber at 2007-11-11 23:13:52 >
# 4 Re: closing db
yes i read somewhere while i was looking for some information in google.
syedwna at 2007-11-11 23:14:53 >
# 5 Re: closing db
there's probably an "IF" before or after that statement. System.Data.CommandBehavior.CloseConnection closes your connection as soon as your ExecuteReader is done doing its job.
kashif_82 at 2007-11-11 23:15:52 >