都是成功了,现在要一一去取那些output参数,返回值和记录集的值  看了一下MS 的在线帮助  http://support.microsoft.com/kb/q185125/#top  里面有这么一句话,  In addition, if the stored procedure is returning output or return parameters, you need to close the recordset before checking the value of the output parameters.   要先关闭记录集,才能取output参数  但问题是,我想先取返回值,再取记录集(我要根据返回值判断那个select有没有成功),取完就关闭,再取output参数值  问题是这样的话,取返回值是ok的,记录集是ok的,然后关闭,但是最后取output参数不对了
  
  我只能先取记录集 ,然后关闭,再取返回值,再取output参数  但是再线帮助,不是说了吗,只要在取output之前关闭就ok了吗??  难道一定要在output和return之前关闭吗?  谁能提供一些建议?或者有经验的?

解决方案 »

  1.   

    取 sp 的返回值不要用 RecordSet,如下:
    Dim cmd As ADODB.Command
    Dim prm As ADODB.ParameterSet cmd = New ADODB.Command
    Set cmd.ActiveConnection = cn
    cmd.CommandText = "? = sp_x()" ‘格式有点忘了,不是很确定Set prm = cmd.CreateParameter("result", adInteger, adParamReturnValue)
    cmd.Parameters.Append prmcmd.ExecuteDebug.Print prm.Value
      

  2.   

    我的sp是这样的CREATE PROCEDURE sp_asdgad
    (
    @out  char(10) output
    )
    as
    BEGIN
    declare @bb int

    select @bb = 1

    select @out = 'test'

    select aaa from table1 

    return @bb
    END如果我先取那个记录集,再取那个@bb,最后@out  是ok的如果先@bb,再关闭记录集,最后@out  ,那个output值不对根据http://support.microsoft.com/kb/q185125/#top
    里的说法必需先关闭记录集,然后取@out但是他没说要先关闭记录集,再去  @bb这个return value阿
    我想知道的是,能否先@bb,再关闭记录集,最后@out  ,还是必要要第一个就关闭记录集
      

  3.   

    set rs=cmd.Execute()
    set rs.activeconnection = nothing '将记录设为非链接的模式
    '接下来访问 prm 和 rs 试试