在vb中怎样调用sql存储过程

解决方案 »

  1.   

    Dim cmd As New ADODB.Command
    Dim rs As New ADODB.Recordset
        Set cmd.ActiveConnection = cn  //cn是连接
        cmd.CommandText = "存储过程名"
        cmd.CommandType = adCmdStoredProc
        cmd.Parameters("@CapitalType") = 值  '@CapitalType存储过程中的参数
        cmd.Parameters("@CountyName") = 值
        Set rs = cmd.Execute
      

  2.   

    Dim cmdReports As New ADODB.Command
            cmdReports.ActiveConnection = Pub_Connection
            cmdReports.CommandText = "proc_report"
            cmdReports.CommandType = adCmdStoredProc
            
            cmdReports.Parameters.Append cmdReports.CreateParameter(, adInteger, adParamInput, 4, 1)
            cmdReports.Parameters.Append cmdReports.CreateParameter(, adVarChar, adParamInput, 4000, Pub_ItemID)
            cmdReports.Parameters.Append cmdReports.CreateParameter(, adDate, adParamInput, 20, RepartDate)
            cmdReports.Parameters.Append cmdReports.CreateParameter(, adVarChar, adParamInput, 20, Pub_CountyName)        cmdReports.Parameters.Append cmdReports.CreateParameter(, adVarChar, adParamInput, 1000, Trim(txtNotifyGroupIdea.Text))
            cmdReports.Parameters.Append cmdReports.CreateParameter(, adVarChar, adParamInput, 20, Pub_BatchType)
            
            
            cmdReports.Execute
      

  3.   

    响 samying  学习~!能不能公开一下你的QQ号或者MSN帐号啊?
      

  4.   

    真想和 samying() 讨论啊,,,,
      

  5.   

    http://blog.csdn.net/online/archive/2004/08/05/66376.aspx
      

  6.   

    昨天才学使用command对象的parameter集合访问存储过程。呵呵。目前只能看懂一点。
      

  7.   

    最简方法
    conn.excute "excute 存储过程名 参数1 参数2"