Dim datefrom As Date
Dim dateto As Date
datefrom = CDate(Text1.Text)
dateto = CDate(Text2.Text)Dim sql1 As String
cn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=cbxx;Data Source=ZSM2"
  Adodc1.ConnectionString = cn
    Adodc1.CommandType = adCmdStoredProc
    Adodc1.RecordSource = "exec proc_tongjijf '" & datefrom & "','" & dateto & "'"
    Adodc1.Refresh
End Sub

解决方案 »

  1.   

    存储过程或SQL语句没有问题吧?
      

  2.   

    为什么不用
    Dim cmd As New ADODB.Command
    Dim rs As New ADODB.Recordset
    cmd来执行你的存储过程?
    ..............
        cmd.CommandType = adCmdStoredProc
        cmd.CommandText = "存储过程名"
        cmd.Parameters.Append cmd.CreateParameter("@参数1", adChar, adParamInput, 20, "参数值")
        set rs = cmd.Execute............
    接下来就可以用rs来取得记录了。