P
Paolo Pignatelli
I have a Function in a Class File that uses ApplicationBlocks:
Public Function GetProductsByCategory(ByVal CategoryID As Integer)
Dim myConnection As SqlConnection = New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim ProductsByCategory As SqlDataReader =
SqlHelper.ExecuteReader(myConnection, CommandType.StoredProcedure,
"ProductsByCategory", New SqlParameter("@CategoryID", CategoryID))
Return ProductsByCategory
End Function
I then access this in a different Tier...(instantiate, etc...) blah blah.
QUESTION: Am I closing the DataReader? I know that this code works, but
occasionally I get faults, and one explanation is that I have not closed
something .
Using a DataSet, (I believe) that I need not worry about this, but how much
am I sacrificing in efficiency by using a DataSet rather than a DataReader?
Any and all suggestions welcome, and
TIA,
Paolo
Public Function GetProductsByCategory(ByVal CategoryID As Integer)
Dim myConnection As SqlConnection = New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim ProductsByCategory As SqlDataReader =
SqlHelper.ExecuteReader(myConnection, CommandType.StoredProcedure,
"ProductsByCategory", New SqlParameter("@CategoryID", CategoryID))
Return ProductsByCategory
End Function
I then access this in a different Tier...(instantiate, etc...) blah blah.
QUESTION: Am I closing the DataReader? I know that this code works, but
occasionally I get faults, and one explanation is that I have not closed
something .
Using a DataSet, (I believe) that I need not worry about this, but how much
am I sacrificing in efficiency by using a DataSet rather than a DataReader?
Any and all suggestions welcome, and
TIA,
Paolo