在Visual Studio中请求超时 [英] Request Timeout in Visual Studio
问题描述
嗨!
我一直收到这个错误:
超时过期。从池中获取连接之前经过的超时时间。这可能是因为所有池连接都在使用中并且达到了最大池大小。
注意:
已经尝试调整连接时间。结果是窗口申请表格悬挂。如何扩展错误中所述的池大小?将保存在数据库中的循环的最大值为250.:
样本:
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)
'MessageBox.Show(pnNumber + ", " +
' Convert.ToString(dateOfPayment) + ", " +
' Convert.ToString(principalAmount) + ", " +
' Convert.ToString(interestAmount) + ", " +
' Convert.ToString(monthlyPayment) + ", " +
' Convert.ToString(balance) + ", " +
' DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + ", " +
' userid)
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
推荐答案
它可以是
1.连接未关闭
2.死锁某处
3.数据库最优查询计划/统计数据
使用Sql Server Management Studio检查死锁连接到数据库。在左窗格中,右键单击服务器节点,然后选择活动监视器。看看正在运行的进程。通常大多数将闲置或运行。出现问题时,您可以通过进程状态识别任何阻止的进程。如果右键单击该过程并选择详细信息,它将显示该过程执行的最后一个查询。
it can be the
1. Connection not closed
2. Deadlock somewhere
3. Database optimal query plan / stats
To check Deadlock Connect to your database with Sql Server Management Studio. In the left pane right-click on the server node and select Activity Monitor. Take a look at the running processes. Normally most will be idle or running. When the problem occurs you can identify any blocked process by the process state. If you right-click on the process and select details it'll show you the last query executed by the process.
The second issue will cause the database to use a sub-optimal query plan. It can be resolved by clearing the statistics:
exec sp_updatestats
请在连接字符串中进行一些更改
1.定义最小池大小和最大池大小
2.定义连接超时时间
两个设置都将在连接字符串中。请更改,检查并确认。
Hi,
Please make Some changes in Connection String
1. define min pool size and Max pool size
2. define Connection Time Out Time
Both settings will be in the connection String. Please change, check and confirm.
尝试在阅读器关闭后关闭。您还进行了一些代码重组,以便在finally块中关闭连接。
Try putting close after reader si closed. You also do some code reorganization so that connection will be closed in finally block.
conn.Close()
http://msdn.microsoft.com/en-us/library/fk6t46tz.aspx [ ^ ]
这篇关于在Visual Studio中请求超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!