dim comm as ado.command
dim para as ado.参数
dim Rs as ado.recodersetset comm=new ado.command
comm.type=存储过程
comm.commtext=存储过程名称
set para=ado.参数
// 参数的初始设置
comm.append paraset rs=comm.执行
//rs的操作,仅读取rs.close
set rs=nothingset para=nothing
//在执行到下一句时弹出提示框
set comm=nothing//以上代码都顺利执行。

解决方案 »

  1.   

    dim comm as ado.command
    dim para as ado.参数
    dim Rs as ado.recodersetset comm=new ado.command
    comm.type=存储过程
    comm.commtext=存储过程名称
    set para=ado.参数
    // 参数的初始设置
    comm.append paraset rs=comm.执行
    //rs的操作,仅读取rs.close
    set rs=nothingset para=nothing
    //在执行到下一句时弹出提示框
    set comm=nothing//以上代码都顺利执行。
      

  2.   

    给你个函数你试试:
    Function RunSPReturnRS(ByVal strSP, params, ByRef OutArray)        On Error GoTo ErrorHandler
                    
            ' Create the ADO objects
            Dim OutPutParms
            Dim rs As New ADODB.Recordset
            Dim cmd As New ADODB.Command
            
            ' Init the ADO objects  & the stored proc parameters
            cmd.ActiveConnection = Conn
            cmd.CommandText = strSP
            cmd.CommandType = adCmdStoredProc
            
            collectParams cmd, params, OutPutParms
            
            ' Execute the query for readonly
            rs.CursorLocation = adUseClient
            rs.CacheSize = AdCacheSize
            rs.Open cmd, , adOpenForwardOnly, adLockReadOnly
            If OutPutParms Then OutArray = collectOutputParms(cmd, params)
            ' Disconnect the recordset and clean up
            ' Disconnect the recordset
            Set cmd.ActiveConnection = Nothing
            Set cmd = Nothing
            Set rs.ActiveConnection = Nothing        ' Return the resultant recordset
            Set RunSPReturnRS = rs
            Exit FunctionErrorHandler:
        RaiseError g_modName, "RunSPReturnRS"
            
    End Function
    Private Sub collectParams(ByRef cmd, ByVal argparams, ByRef OutPutParms)
            Dim params, v
            Dim I, l, u
            'if argparams is empty
            
            If Not IsArray(argparams) Then Exit Sub
            
            OutPutParms = False
            params = argparams
            For I = LBound(params) To UBound(params)
                l = LBound(params(I))
                u = UBound(params(I))
                ' Check for nulls.
                If u - l >= 3 Then
                    If VarType(params(I)(4)) = vbString Then
                        If params(I)(4) = "" Then
                            v = Null
                        Else
                            v = params(I)(4)
                        End If
                    Else
                        v = params(I)(4)
                    End If
                    If params(I)(2) = adParamOutput Then OutPutParms = True
                    cmd.Parameters.Append cmd.CreateParameter(params(I)(0), params(I)(1), params(I)(2), params(I)(3), v)
                Else
                    RaiseError g_modName, "CollectParms"
                End If
            Next
            
    End Sub
      

  3.   

    Private Function collectOutputParms(ByRef cmd, argparams)
            Dim params, v, OutArray(20)
            Dim I, l, u
            'if argparams is empty
            
            'If Not IsArray(argparams) Then Exit Sub
            
            params = argparams
            For I = LBound(params) To UBound(params)
                OutArray(I) = cmd.Parameters(I).Value
            Next
            collectOutputParms = OutArray
    End Function
      

  4.   

    衊?衊?衊?㘓뿶衊?㘓뿶衊?㘓뿶਴?Ꮲ뿶ů?衊?Ζ衊?㘓뿶ਸ?Ꮲ뿶ů???衊?㘓뿶ਸ?Ď???衊?㘓뿶ਸ?Ꮲ뿶ů???鏠ē儀Ǭ뺤衊?㘓뿶ਸ?Ď????衊?㘓뿶ਸ?Ď?????衊?㘓뿶ਸ?Ꮲ뿶ů?衊?㘓衊?㘓뿶ਸ?衊?㘓뿶
    衊?㘓뿶ਸ?Ꮲ뿶ů???ǰĺ儀Ǭ뺤 衊?㘓뿶ਸ?Ď???衊?㘓뿶衊?㘓衊?
      

  5.   

    //在执行到下一句时弹出提示框
    //add: comm.close
    set comm=nothing//以上代码都顺利执行。
      

  6.   

    Sub RaiseError(module As String, functionName As String)
     
       Dim lErr As Long
       Dim sErr As String
       lErr = VBA.Err.Number
       sErr = VBA.Err.Description
        
       App.LogEvent (Err.Description)
       Err.Raise lErr, SetErrSource(module, functionName), Err.Description
    End Sub
      

  7.   

    ADO调用存储过程:dim cn as adodb.connection
    dim rs as adodb.recordset
    .
    .
    .
    dim sql as string
    sql=" { call 存储过程名(参数列表) }"
    rs.open sql,cn这种方法调用最简单
      

  8.   

    和你说一个办法,如果以上办法解决不了的话,你就将那一部分提出来,做一个dll,这样就不用每次编译了。