My asp.net program try to use a loop to insert data into a table. There are about 5000 records need to be inserted.
But for a while, I got an error message said:
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.
I checked my code. It open connection and close connection each insertion.
How to fix it?
Here is partial code below. MYORDER is a value from another function for each insertion .
Dim myConn As New SqlConnection(MYSQLCONNECTIONSTRING)
Dim strSQL As String
strSQL = " insert into order"
strSQL += "([ORDERNO])"
strSQL += " values(@ORDERNO)"
Dim cmd As New SqlCommand(strSQL, myConn)
cmd.CommandType = CommandType.Text
With cmd
.Parameters.Add(New SqlParameter("@ORDERNO", SqlDbType.V ...
Go to the complete details ...