Dim iCmd As ADODB.Command
Dim iConc$iConc=数据库连接字符串
Set iCmd = New ADODB.Command
With iCmd
    .ActiveConnection = iConc
    .CommandType = adCmdStoredProc
    .CommandText = "你的存储过程"
    .Parameters.Refresh
    .Parameters("@参数")=值
    .Execute
End With
End Sub

解决方案 »

  1.   

    '** ----- 数据库连接字符串模板 ---------------------------------------
    '** SQL数据库
    '** iConcStr = "Provider=SQLOLEDB.1;Persist Security Info=True;" & _
    '**     "User ID=用户名;Password=密码;Initial Catalog=数据库名;Data Source=SQL服务器名"
      

  2.   

    '如果存储过程返回的是表结果,就用:Dim iCmd As ADODB.Command,iRe as adodb.Recordset
    Dim iConc$iConc=数据库连接字符串
    Set iCmd = New ADODB.Command
    With iCmd
        .ActiveConnection = iConc
        .CommandType = adCmdStoredProc
        .CommandText = "你的存储过程"
        .Parameters.Refresh
        .Parameters("@参数")=值
       set iRe=.Execute
    End With
       msgbox ire(0)  '对结果的再处理
    End Sub
      

  3.   

    '如果是存储过程的输出参数
    Dim iCmd As ADODB.Command
    Dim iConc$iConc=数据库连接字符串
    Set iCmd = New ADODB.Command
    With iCmd
        .ActiveConnection = iConc
        .CommandType = adCmdStoredProc
        .CommandText = "你的存储过程"
        .Parameters.Refresh
        .Parameters("@参数")=值
        .Execute
        msgbox .Parameters("@输出参数")
    End With
    End Sub
      

  4.   

    我刚刚试一下,我是这样写的.
    可惜不行出错,对象关闲,操作不被允许!请指教!
    我在查询器使用是可以运行的存储过程的!  Dim i As Long
        Dim adoPro As New ADODB.Command
        Dim adoRs As New ADODB.Recordset
        With adoPro
            .ActiveConnection = conOpen
            .CommandType = adCmdStoredProc
            .CommandText = "sp_movein"
            .Parameters.Refresh
            .Parameters("@strCnee") = "MEAL"
            Set adoRs = adoPro.Execute
        End With
        With MSFlexGrid1
            If adoRs.RecordCount > 0 Then
                For i = 1 To adoRs.RecordCount
                    .TextMatrix(i, 1) = adoRs.Fields(0).Value
                    adoRs.MoveNext
                Next i
            Else
            
            End If
        End With