I always think it is a good idea to keep track of my connections, no matter wich way I'm connecting to a database.
You said that you always use a datareader, but now you are using a data set. I'm assuming that means you are using a DataAdapter
to go with your DataSet
. If that is the case, and you are using MSSQL, then the SqlDataAdapter
will open and close the connection for you, but like I said, I like to keep track of this myself, especially since you may use SqlCommand.ExecuteScalar
(even if you are using a DataAdapter
most of the time) at some point, and the SqlCommand
will not manage your connection state for you.
SqlDataAdapter
doc:
http://msdn.microsoft.com/en-us/library/zxkb3c3d.aspx