3

从 Access VBA 执行时,以下 SP 超时。从管理控制台执行时它工作正常。如果相关,服务器确实有很长的 ping 时间:

Dim cnn As ADODB.Connection
Dim cmd As New ADODB.Command, rs As New ADODB.Recordset, param As New ADODB.Parameter
Dim fld As ADODB.Field
Dim stMessage As String


Set cnn = New ADODB.Connection
cnn.ConnectionString = "DRIVER=SQL Server;SERVER=server01;DATABASE=db_a;Trusted_Connection=Yes"

cnn.Open cnn.ConnectionString

Set cmd = New ADODB.Command
cmd.ActiveConnection = cnn
cmd.CommandType = adCmdStoredProc

    cmd.CommandText = "we_ci_db.stprUpdateValuesInitial_A"

    Set param = cmd.CreateParameter("@DataSet", adInteger, adParamInput, , stDataSet)
    cmd.Parameters.Append param

    rs.CursorType = adOpenStatic
    rs.CursorLocation = adUseClient
    rs.LockType = adLockOptimistic

    Set rs = cmd.Execute


exit1:
Set cmd = Nothing
Set rs = Nothing
Exit Function
4

1 回答 1

3

CommandTimeout您可以使用对象的属性设置超时ADODB.Command

// set a very high number of seconds before timeout
cmd.CommandTimeout = 9999999
于 2013-01-20T17:53:32.877 回答