忘 了说是通过asp程序无法获得

解决方案 »

  1.   

    这个问题我现在也头疼!!
    cREATE proc select_prize
      @begindate datetime,
      @enddate datetime,
      @companyaccount [varchar](200),
      @content [varchar](100),
      @m int ,
      @n int
    as
    declare @csql varchar(600)
    --declare @csql1 char(600)
    if @m<>""  
    begin
    set @csql='   select  top  '+cast(@m as nchar)+'  callnumber , times = count(callnumber) into #temptable from OUUpSM_Original 
    where  success=1 and  content="'+@content+'"   and compaccount='''+@companyaccount +'''  and receivetime  between  '' '+cast(@begindate as nchar)+'''   and  '''+ cast(@enddate as nchar) +''' group by callnumber  order  by times desc     select top '+cast(@n as nchar)+ ' * from #temptable  order by newid()       '
    end
    if @m="" and cast(@n as nchar)<>''''
    begin
    set @csql='   select   callnumber , times = count(callnumber) into #temptable from OUUpSM_Original 
    where  success=1 and  content="'+@content+'"  and compaccount='''+@companyaccount +'''  and receivetime  between  '' '+cast(@begindate as nchar)+'''   and  '''+ cast(@enddate as nchar) +''' group by callnumber  order  by times desc     select top '+cast(@n as nchar)+ ' * from #temptable  order by newid()    drop table  #temptable  '
    end
    --print @csql
    exec (@csql)
    GO
    我的存储过程看起来复杂,其实就是从一个表A中取出符合条件的纪录,插入到一个临时表#temptable中,然后再从#temptable中取出符合所要的纪录,然后再把临时表释放掉,
    在asp中调用如下:
    <%
     set rsinsert=server.CreateObject("adodb.recordset")
     str="exec select_prize '"& begint &"','"&endt&"','"&CompanyAccount&"','"&content&"',"&totalnumber&","&pplnum
     response.write str
     rsinsert.Open str,connectstring,3,1
     Response.Write "<br>"& rsinsert.RecordCount
     可什么也没有输出,但是把输出的str在query中执行后,有两条纪录
     到底是为什吗?我最后发现是因为临时表的问题
    如果说是因为用到了临时表,那我应该怎么办???怎吗改????才能返回rs记录集??
    %>
      

  2.   

    在as后面加上
    set nocount on
    如果不行,我就over了
      

  3.   

    用记录集来做存储过程的执行调用试一下,如下:recordset.open (存储过程名 参数1,参数2,…………),connection,,,,adcmdtable
      

  4.   

    对了少一个应该是这样的
    recordset.open (exec 存储过程名 参数1,参数2,…………),connection,,,,adcmdtable 
      

  5.   

    不行,我加了set nocount on 可结果是-1,到地位什吗呀???
      

  6.   

    加了set nocount on ,可返回结果是-1
      

  7.   

    去掉
    drop table  #temptable