D
David C
I have some class functions that return SqlDataReader to fill DropDownLists.
Below is example. I have the RETURN line before the closing of reader and
connection. Are these getting closed or is there another way to do this?
For example, if I had it wrapped in a Using block? I am getting connection
pool timeouts and am only testing the site so I'm not sure why. Thanks in
advance.
David
Public Shared Function GetWICounties() As SqlDataReader
Dim conData As SqlConnection = New
SqlConnection(ConfigurationManager.ConnectionStrings("MCFICoreConnectionString").ConnectionString)
conData.Open()
Dim strSQL As String
strSQL = "SELECT CountyID, County" & _
" FROM dbo.WICounties" & _
" ORDER BY County"
Dim cmdSel As SqlCommand = New SqlCommand(strSQL, conData)
Dim dtr As SqlDataReader = cmdSel.ExecuteReader()
Return dtr
dtr.Close()
conData.Close()
End Function
Below is example. I have the RETURN line before the closing of reader and
connection. Are these getting closed or is there another way to do this?
For example, if I had it wrapped in a Using block? I am getting connection
pool timeouts and am only testing the site so I'm not sure why. Thanks in
advance.
David
Public Shared Function GetWICounties() As SqlDataReader
Dim conData As SqlConnection = New
SqlConnection(ConfigurationManager.ConnectionStrings("MCFICoreConnectionString").ConnectionString)
conData.Open()
Dim strSQL As String
strSQL = "SELECT CountyID, County" & _
" FROM dbo.WICounties" & _
" ORDER BY County"
Dim cmdSel As SqlCommand = New SqlCommand(strSQL, conData)
Dim dtr As SqlDataReader = cmdSel.ExecuteReader()
Return dtr
dtr.Close()
conData.Close()
End Function