Dim comm As New ADODB.Command
  
  comm.ActiveConnection = 联接
  comm.CommandText = "存储过程名"
  comm.CommandType = adCmdStoredProc
  
  comm.Parameters.Append comm.CreateParameter("参数名", adDate, adParamInput, , 变量)
  comm.Execute

解决方案 »

  1.   

    '存储过程,返回用户号是否存在
    Public Function FindId(ID1 As Single) As Boolean
        Dim pra_user_id As New ADODB.Parameter
        Dim pra_user_exist As New ADODB.Parameter
        Dim cmd_IsIdExist As New ADODB.Command
        
        pra_user_id.Direction = adParamInput
        pra_user_id.Type = adSingle
        pra_user_id.Size = 9
        pra_user_id.Value = ID1
      
        pra_user_exist.Direction = adParamOutput
        pra_user_exist.Type = adBoolean
        pra_user_exist.Size = 1
        
        cmd_IsIdExist.ActiveConnection = adoCnConnect
        cmd_IsIdExist.CommandType = adCmdStoredProc
        cmd_IsIdExist.CommandText = "prc_Find_ID"
        cmd_IsIdExist.Parameters.Append pra_user_id
        cmd_IsIdExist.Parameters.Append pra_user_exist
        cmd_IsIdExist.Execute
        FindId = pra_user_exist.Value
    End Function
      

  2.   

    设置dataenviment的connection属性,把数据源设为存储过程。
      

  3.   

    数据源的连接
    DIM adocn as new adodb.connection
    adocn.open "Server=sqlserver;Server=soft;UID=sa;PWD=;Database=CHILDREN;"
      

  4.   

    简单例子:
    strSQL = "pdCQA '" & dtBegin & "','" & dtEnd & "'," & lngTypeID
    Set rsRet = adoConn.Execute(strSQL)
      

  5.   

    用我刚才给你的那个函数(不过你要改一改)
    dim a as single
    dim b as boolean
    a=val(text1.text)
    b=FindId(a) 
    msgbox b
    'a是id号作为传入参数b是该id是否存在,是返回参数
      

  6.   

    '定义全局连接
    public g_CN as ADODB.ConnectionPublic Sub GetSumByTitle(ByVal pTitle As String, _
        pSum as Currency)Dim lcmRev As Command
    Dim strCon as stringOn Error GoTo GetRevErr    If g_CN Is Nothing Then        '初始化数据库连接字符串
            strCon = "Provider=SQLOLEDB.1;Persist Security Info=false;UID=" & _
                mstrLogin & ";PWD=" & mstrPassword & _
                ";Initial Catalog=" & mstrDB & ";Data Source=" & _
                mstrServer
            
        End If
        
        '初始化数据库连接
        'Create the connection object if it doesn't exist
        If g_CN Is Nothing Then
            Set g_CN = New ADODB.Connection
            'set the connection properties
            With g_CN
                .ConnectionString = strCon
                .CommandTimeout = 30
                .ConnectionTimeout = 60
            End With
        End If
        
        'Connect if not already connected
        If g_CN.State = adStateClosed Then
            'Connect to the database
            g_CN.Open
        
        End If
    ' Create the Command
    Set lcmRev = New Command
    With lcmRev
        .CommandText = "titles_sum"
        .CommandType = adCmdStoredProc
        .ActiveConnection = g_CN
    End With' Create and append the parameters, both input and output
    lcmRev.Parameters.Append lcmRev.CreateParameter("@title", _
        adVarchar, adParamInput, 40, pTitle)
    lcmRev.Parameters.Append lcmRev.CreateParameter("@sum", _
        adCurrency, adParamOutput, 4)' Execute the command
    lcmRev.Execute , , adExecuteNoRecords' Read the output parameters
    pSum = lcmRev.Parameters("@sum")' Deallocate
    Set lcmRev = NothingExit Sub
    GetRevErr:
        ' Raise an error and deallocate
        Err.Raise vbObjectError + 807, "GetSumByTitle", Err.DescriptionEnd Sub