Hi!
I keep getting this 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.
Note:
Already tried to adjust connection time. The results was the windows application form is hanging. How do I expand the pool size that is said in the error? The maximum value of a loop that will save in a database is 250. :|
Sample:
For x As Integer = 0 To (250 - 1)
InsertToDB(pnNumber, dateOfPay, Math.Round(principal_payments, 2), Math.Round(interest_payments, 2), Math.Round(monthly_payment, 2), Math.Round(balance, 2))
Next
Private Sub InsertToDB(ByVal pnNumber As String, ByVal dateOfPayment As String, ByVal principalAmount As Double, ByVal interestAmount As Double,
ByVal monthlyPayment As Double, ByVal balance As Double)
Try
Dim conn As SqlConnection
Dim comm As SqlCommand
Dim reader As SqlDataReader
Dim connectionString As String = ConfigurationManager.ConnectionStrings("msSqlConnectionString1").ConnectionString
conn = New SqlConnection(connectionString)
comm = New SqlCommand()
comm.Connection = conn
comm.CommandType = CommandType.StoredProcedure
comm.CommandText = "sp_SetPNAmort"
comm.Parameters.Add("@PNNumber", Data.SqlDbType.NVarChar)
comm.Parameters.Add("@periodDate", Data.SqlDbType.NVarChar)
comm.Parameters.Add("@principalAmount", Data.SqlDbType.Float)
comm.Parameters.Add("@interestAmount", Data.SqlDbType.Float)
comm.Parameters.Add("@payment", Data.SqlDbType.Float)
comm.Parameters.Add("@osBalance", Data.SqlDbType.Float)
comm.Parameters.Add("@dateGenerated", Data.SqlDbType.NVarChar)
comm.Parameters.Add("@uploadedBy", Data.SqlDbType.NVarChar)
comm.Parameters("@PNNumber").Value = pnNumber
comm.Parameters("@periodDate").Value = dateOfPayment
comm.Parameters("@principalAmount").Value = principalAmount
comm.Parameters("@interestAmount").Value = interestAmount
comm.Parameters("@payment").Value = monthlyPayment
comm.Parameters("@osBalance").Value = balance
comm.Parameters("@dateGenerated").Value = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
comm.Parameters("@uploadedBy").Value = userid
conn.Open()
reader = comm.ExecuteReader()
reader.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Alert!!!")
End Try
End Sub