con pool

farshad

Well-known member
Joined
May 1, 2003
Messages
109
Location
London
Hi,
I am getting an error message about max con pool size is reached
As you can see the error is in a class module which I am calling from a form to do an update.
In the form I loop through this datareader and after the loop I use oDr.close
oDr=nothing

-------------------------------------------
Public Function UpdateDurations(ByVal strIdentifier As String, ByVal dblDuration As Double) As SqlDataReader
Dim strSQL As String = "CSA_SP_UpdateDurations"
Dim oCon As SqlConnection
Dim oCmd As SqlCommand

Try
oCon = New SqlConnection(ConnectToDB)
oCmd = New SqlCommand(strSQL, oCon)

With oCmd
.CommandType = CommandType.StoredProcedure

.Parameters.Add("@Identifier", SqlDbType.VarChar, 50)
.Parameters("@Identifier").Value = strIdentifier

.Parameters.Add("@Duration", SqlDbType.Float, 8)
.Parameters("@Duration").Value = dblDuration

oCon.Open()
Return .ExecuteReader(CommandBehavior.CloseConnection)
End With

Catch ex As Exception
Throw ex
End Try
End Function
-------------------------------------------

Do you know why I am getting this error in the class module?
THanks
 
What are you doing with the data reader after you return it from the function? Did you remember to close and destroy it? Are you calling your UpdateDurations function in a loop where you might be creating connection after connection without dropping them?
 
Back
Top