要增加超时时间 [英] To increase the timeout period

查看:173
本文介绍了要增加超时时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要增加超时period.Following是我的code。

I have to increase timeout period.Following is my code.

Private Function GetConnectionInstance() As SqlConnection
    Dim objConn As SqlConnection
    Dim strConnection As String
    strConnection = ConfigurationSettings.AppSettings("conn")

    Try
        objConn = New SqlConnection(strConnection)
    Catch ex As Exception
    End Try

    Return objConn
End Function

什么$ C $词要在上面添加,以增加超时时间。

What code i have to add in above to increase timeout period.

推荐答案

您需要到下一个项目添加到您的连接字符串:

You need to add the next item into your connection string:

连接超时= 30;

如果您需要更改超时只为目标连接,而不是在整个应用程序,下一步:

If you need to change Timeout only for target connection, not in the whole application, do next:

Dim connString as String = ConfigurationSettings.AppSettings("conn")
Dim builder As New SqlConnectionStringBuilder(connString)
builder.ConnectTimeout = 30;
Dim connection = New SqlConnection(builder.ToString())

这篇关于要增加超时时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆