本人在学习用vb调用服务器存储过程进行查询的方法,但是遇到了问题
就是在查询器中使用存储过程可以正常返回记录集,但是用vb调用则
返回的记录集为空调用语句如下
Set biaotemp = cnn.Execute("exec dquery1 '2002-07-01','2002-08-01','01'")
返回的记录集为空
请教各位是怎么回事啊?

解决方案 »

  1.   

    set biaotemp = cnn.Execute "dquery1('2002-07-01','2002-08-01','01')", , adCmdStoredProc
      

  2.   

    你可能要在存储中加兩句:
    Create Procedure myProc
    As SET NOCOUNT ON   --開始加第一句/*
    your Code ......... 
    */SET NOCOUNT OFF   --最後還加一句
      

  3.   

    我参照网上的例子换了种写法
    Dim parm_startime As ADODB.Parameter '参数1
    Dim parm_endtime As ADODB.Parameter '参数2
    Dim startime As Data
    Dim endtime As Data
    Set mycommand = New ADODB.Command
    Set parm_startime = New ADODB.Parameter
    parm_startime.Name = "startime"
    parm_startime.Type = adDBDate '参数类型
    'parm_startime.Size = 8 '参数长度
    parm_startime.Direction = adParamInput '参数方向,输入或输出
    parm_startime.Value = #7/1/2002#
    mycommand.Parameters.Append parm_startime   '加入参数
    Set parm_endtime = New ADODB.Parameter
    parm_endtime.Name = "endtime"
    parm_endtime.Type = adDBDate
    'parm_endtime.Size = 3
    parm_endtime.Direction = adParamInput
    parm_endtime.Value = #8/1/2002#
    mycommand.Parameters.Append parm_endtime
    mycommand.ActiveConnection = cnn
    '指定该command 的当前活动连接
    mycommand.CommandText = "pinlei1"
    'myprocedure 是你要调用的存储过程名称
    mycommand.CommandType = adCmdStoredProc
    '表明command 为存储过程
    Set biaotemp = New ADODB.Recordset
    biaotemp.CursorLocation = 3
    biaotemp.CursorLocation = adUseClient
    biaotemp.CursorType = adOpenStatic
    biaotemp.LockType = adLockReadOnly
    Set biaotemp = mycommand.Execute()
    但是运行到
    Set biaotemp = mycommand.Execute()
    系统报错
    “[microsoft][ODBC SQL Server Driver]
      Optional feature not implememted”
    是不是我传递的参数有问题?存储过程代码如下------------------
    CREATE PROCEDURE pinlei1 (@startime  datetime,@endtime datetime) AS
    select a.药品编码,a.数量合计,a.销售额,catalog.购进价,a.数量合计*catalog.购进价 as 成本,catalog.品类 from catalog,
    (select 药品编码,sum(数量) as 数量合计,sum(数量*单价*折扣比例/100) as 销售额  from retail where 
    发生时间>@startime and 发生时间<@endtime
    and (类别='销售' or 类别='退货') group by 药品编码) as a
     where a.药品编码=catalog.药品编码
    GO
    请求各位指点了
      

  4.   

    CREATE PROCEDURE test  
    @dwbh CHAR(7),  
    @S1   CHAR(7) OUTPUT  
     AS
    SElect @S1=MAX(ID)  
    select @s1 as s1 
    private sub refreshlist()  
    dim rs as recordset  
    set rs=mconn.execute("test",,adcmdstoredproc)  
    txt.text=rs("s1")  
    end sub