开发者

Provider Factory Command Timeout - how to set it

I am having a problem with a SQL server query giving a timeout error. I read about setting the timeout value of the command object but in my DAL, I do not see how to do that. Here is how I create the command object

Public Sub Init()
    If ConnString = "" Then
        Select Case ConnStringID
            Case "SQL"
                ConnString = theSQLConnectionString
                Provider = "System.Data.SqlClient"
            Case "Access"
                ConnString = theAccessConnection开发者_如何学PythonString
                Provider = "System.Data.OleDb"
        End Select
    End If
    If Conn Is Nothing Then
        PFactory = DbProviderFactories.GetFactory(Provider)
        Conn = PFactory.CreateConnection
        Conn.ConnectionString = ConnString
        Cmd = PFactory.CreateCommand
    End If
End Sub

I do not see a property of Cmd for CommandTim


What you need is, for example:

Cmd.CommandTimeout = 30 'Seconds

If this does not autocomplete, make sure Cmd is declared as type DbCommand.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜