DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   VB.NET (http://www.daniweb.com/forums/forum58.html)
-   -   Error : Timeout expired. ...... max pool size was reached (http://www.daniweb.com/forums/thread66452.html)

artee Jan 5th, 2007 12:57 pm
Error : Timeout expired. ...... max pool size was reached
 
I get the following error
"Timeout expired. the timeout period elapsed prior to obtaining a connection from the pool. this may have occurred because all pooled connections were in use and max pool size was reached."

The below code is in the click event of the Upload button. This works fine when it is executed the first time (for loop, loops thru around 100 records). However, when I click the button the second time, it displays the above error after looping around 6 to 8 times.

As far as I know, I am closing the connection.
What am I doing wrong?
Please help
- Artee

Private Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpload.Click
Dim con As New ConnectClass
Dim myConnect As String
Dim cmdString As String
Dim i As Integer, j As Integer
Dim ds1 As New DataSet
Dim dv2 As New DataView
ds1.Merge(mCSV.CSVDataSet.Tables(0).Copy)
ds1.Clear()
 
 
dv2 = New DataView(ds1.Tables(0))
For i = 0 To mCSV.CSVDataSet.Tables(0).DefaultView.Count - 1
 
 
cmdString = " Select * from SCHDB.dbo.DistrictAll " & _
" where DCode = '" & dgrdView1.Item(i, 0) & "'"
 
Dim da As New SqlDataAdapter(cmdString, con.GetDBConnection)
If da.SelectCommand.ExecuteReader.HasRows = False Then
Else
 
Dim drv As DataRowView = dv2.AddNew
For j = 0 To 13
drv(ColNameCheck(j)) = dgrdView1.Item(i, j)
Next
End If
 
da.Dispose()
con.GetDBConnection.Dispose()
 
Next
dgrdUploadedAll.DataSource = dv2
con.GetDBConnection.Close()
End Sub


All times are GMT -4. The time now is 1:08 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC