Click here to Skip to main content
15,897,704 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Label control's text property Pin
minhpc_bk11-Oct-06 15:15
minhpc_bk11-Oct-06 15:15 
QuestionAbout Annotation Pin
sribachana11-Oct-06 2:57
sribachana11-Oct-06 2:57 
AnswerRe: About Annotation Pin
Mike Ellison11-Oct-06 5:42
Mike Ellison11-Oct-06 5:42 
GeneralRe: About Annotation [modified] Pin
sribachana12-Oct-06 1:15
sribachana12-Oct-06 1:15 
GeneralRe: About Annotation Pin
Mike Ellison12-Oct-06 6:20
Mike Ellison12-Oct-06 6:20 
QuestionRequiredFieldValidation Pin
MHASSANF11-Oct-06 2:43
MHASSANF11-Oct-06 2:43 
AnswerRe: RequiredFieldValidation Pin
minhpc_bk11-Oct-06 15:17
minhpc_bk11-Oct-06 15:17 
QuestionProblem with sqlserver connections not closing Pin
macca2411-Oct-06 1:39
macca2411-Oct-06 1:39 
I have an application which has dropdown list which is populated with values from a database table. The dropdown list is populated by a subroutine which in turn calls a function. The function uses a stored procedure to get the datat for the dropdown from the database table. Here is the code that is used:

THIS IS THE SUBROUTINE

Private Sub GetDepartments()
'************************************************************
' This method populates the Depts dropdown with a list
' of departments
'************************************************************

MODULE_NAME = "GetDepartments"

Dim oStaff As Staff
Dim oDR As SqlDataReader

Try
oStaff = New Staff
oDR = oStaff.GetDepartments()

ddlSignedBy.Items.Add(New ListItem("", 0))
While oDR.Read()
ddlSignedBy.Items.Add(New ListItem(oDR("Dept_tdp").ToString(), oDR("DeptId_tdp").ToString()))
End While
oDR.Close()

Catch objException As Exception
'Display the exception message
Dim strError As String = objException.Message
If Not IsNothing(objException.InnerException) Then
strError += objException.InnerException.Message
End If

Finally
' Clean Up
oStaff = Nothing
oDR = Nothing
End Try

End Sub

THIS IS THE FUNCTION IT CALLS

Public Function GetDepartments() As SqlDataReader
'****************************************
' This method gets list of departments
'****************************************

MODULE_NAME = "GetDepartments"

Dim Conn As New SqlConnection(sqlcon)
Dim SqlCom As SqlCommand
Dim Param As SqlParameter

Try
Conn.Open()

SqlCom = New SqlCommand("sproc_GetDept", Conn)
SqlCom.CommandType = CommandType.StoredProcedure

Return SqlCom.ExecuteReader()

Catch objException As Exception
'Raise an exception
Dim strError As String = " [SubClass: " & CLASS_NAME & ", SubModule: " & MODULE_NAME & "] " & objException.Message
If Not IsNothing(objException.InnerException) Then
strError += objException.InnerException.Message
End If

Throw (New Exception(strError))

Finally
' Clean Up
SqlCom.Dispose()
SqlCom = Nothing
Conn = Nothing

End Try

End Function

The problem I have is that the database connection that is opened by the Stored Procedure sproc_GetDept is not getting closed. If I decide to close the connection in the Function then the oDR.Read cannot perform in the Subroutine.
Thsi is causing all the connections in the connection pool of the database to be used up.

Anyone any ideas how toget over this.

Thanks
macca
AnswerRe: Problem with sqlserver connections not closing Pin
l0kke11-Oct-06 4:08
l0kke11-Oct-06 4:08 
GeneralRe: Problem with sqlserver connections not closing Pin
macca2411-Oct-06 5:06
macca2411-Oct-06 5:06 
AnswerRe: Problem with sqlserver connections not closing Pin
l0kke11-Oct-06 5:03
l0kke11-Oct-06 5:03 
AnswerRe: Problem with sqlserver connections not closing Pin
Ramasubramaniam11-Oct-06 5:30
Ramasubramaniam11-Oct-06 5:30 
GeneralRe: Problem with sqlserver connections not closing Pin
macca2411-Oct-06 5:34
macca2411-Oct-06 5:34 
GeneralRe: Problem with sqlserver connections not closing Pin
macca2411-Oct-06 23:07
macca2411-Oct-06 23:07 
AnswerI might just be blind but... Pin
nlindley712-Oct-06 11:03
nlindley712-Oct-06 11:03 
Questionwebservices Pin
kavithapuranik11-Oct-06 0:55
kavithapuranik11-Oct-06 0:55 
Questionplease Pin
choorakkuttyil11-Oct-06 0:25
choorakkuttyil11-Oct-06 0:25 
AnswerRe: please Pin
_AK_11-Oct-06 0:29
_AK_11-Oct-06 0:29 
GeneralRe: please Pin
choorakkuttyil11-Oct-06 0:35
choorakkuttyil11-Oct-06 0:35 
GeneralRe: please Pin
_AK_11-Oct-06 0:41
_AK_11-Oct-06 0:41 
GeneralRe: please Pin
choorakkuttyil11-Oct-06 0:45
choorakkuttyil11-Oct-06 0:45 
GeneralRe: please Pin
_AK_11-Oct-06 0:52
_AK_11-Oct-06 0:52 
GeneralRe: please Pin
choorakkuttyil11-Oct-06 0:54
choorakkuttyil11-Oct-06 0:54 
GeneralRe: please Pin
_AK_11-Oct-06 0:55
_AK_11-Oct-06 0:55 
GeneralRe: please Pin
choorakkuttyil11-Oct-06 1:16
choorakkuttyil11-Oct-06 1:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.