Temporary error for SQL stored procedures in Access

When run from Access, VBA runs the next SP. It works great when executed from the management console. If it matters, the server has a long ping time:

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

      

+3


source to share


1 answer


You can set the timeout using the CommandTimeout

object property ADODB.Command

:



// set a very high number of seconds before timeout
cmd.CommandTimeout = 9999999

      

+3


source







All Articles