在VB中用如下代码试试,因为从代码看是否有可能不会返回任何值。
set rs=db.execute(sql)
if rs.state=1 then   '记录集是否已打开
   while not rs.eof
     '处理记录集
   wend
end if

解决方案 »

  1.   

    Set cmd = New ADODB.Command
    With cmd
        .ActiveConnection = con
        .CommandType = adCmdStoredProc
        .CommandText = "findjsdmgs"
        .Parameters.Append .CreateParameter("@jsdm", adChar, adParamInput, 7, "具体数值")
        .Parameters.Append .CreateParameter("@r1q", adChar, adParamInput, 7, "具体数值")
        .Parameters.Append .CreateParameter("@r1z", adChar, adParamInput, 7, "具体数值")
        
    End With
    Set rs = cmd.Execute用命令对象试试
      

  2.   

    CREATE   PROCEDURE  findjsdmgs  @jsdm char(7), @r1q char(7), @r1z char(7)
    AS
    set nocount on--add*************************************************************
    if object_id('tempdb..##temp1') is not null 
    drop table ##temp1
    if object_id('tempdb..##temp') is not null 
    drop table ##tempdeclare @sql varchar(8000)
    declare @dwmc char(40)
    select c.dwmc,a.gs,sum(a.sl)as sl ,convert(varchar(7),a.r1,120)  as r1 into ##temp1 from slk a left join gs b on a.gs=b.gs left join dwxx c on b.jsdm1=c.jsdm
    where convert(varchar(7),r1,120)>=@r1q  and convert(varchar(7),r1,120)<=@r1z  and b.jsdm1=@jsdm
    group by a.gs,convert(varchar(7),a.r1,120),c.dwmcif object_id('tempdb..##temp1') is not null 
    if exists(select top 1 * from ##temp1)
    begin
    select @dwmc=dwmc from ##temp1
    if @dwmc is not null
    begin
    set @sql = 'select dwmc as 单位名称,gs as 给水号,'
    select @sql = @sql + 'sum(case r1 when '''+r1+''' 
                              then sl else 0 end) as '''+r1+''' ,' from (select distinct r1  from ##temp1 ) as a
    select @sql = left(@sql,len(@sql)-1)
    exec(@sql + 'into ##temp  from ##temp1  group by gs,dwmc')
    set nocount on 
    select * from ##temp
    end 
    end 
    set nocount offGO
      

  3.   

    在存储过程第一行加上:set nocount on