请教各位一个问题 环境如下 
(1) 我在sql server 上建立一个 存储过程 VB_Xlstyl1
(2) 客户端用 VB+ADO 调用 VB_Xlstyl1,然后在VB中显示字段 rtstyl (3) 但VB出现了如下错误 :
    实时错误 '3265' : 
    在对应所需名称或序数的集合中,未找到项目。(4) 如果在存储过程加上一句 ,"set nocount on", vb程序就可以正常运行. 如果我有很多个 存储过程,是否每个都要加上 "set nocount on" ,是否有简单的方法解决这个问题 
(1) 设置 ADO 的属性可以吗? 
(2) 设置 SQL SERVER 的属性可以吗? 
(3) 还有其他简单的方法吗?    
附 : 
create proc VB_Xlstyl1 as
Declare @BBB table (tstyl char(16),tcont int) Insert @BBB (tstyl,tcont) 
select xsstyl,count(*) from xlstyle 
where xsstyl <> '' group by xsstyl having count(*) >1 select rtstyl=xsstyl from xlstyle where xsstyl <> '' and xspric is null 
Go

解决方案 »

  1.   

    1) 我在sql server 上建立一个 存储过程 VB_Xlstyl1
    (2) 客户端用 VB+ADO 调用 VB_Xlstyl1,然后在VB中显示字段 rtstyl (3) 但VB出现了如下错误 :
        实时错误 '3265' : 
        在对应所需名称或序数的集合中,未找到项目。//似呼是因为返回了多个记录集,可能是Rst只记得了最后的一个.而你调用的是哪个字段?可能是Rst得到了你的最后一个Select
    (4) 如果在存储过程加上一句 ,"set nocount on", vb程序就可以正常运行. 因为是记数的,可能是加上这句则呼略Insert和Select rtsty1=...这些,只顺记录集.
    Set nocount on 
    如果我有很多个 存储过程,是否每个都要加上 "set nocount on" ,//一般的存储过程是什么样的?会存在返回多个记录集的情况吗?我写存储过程一般是不用加的
    是否有简单的方法解决这个问题 
    (1) 设置 ADO 的属性可以吗? 
    (2) 设置 SQL SERVER 的属性可以吗? 
    (3) 还有其他简单的方法吗?//似呼是不可以.
    附 : 
    create proc VB_Xlstyl1 as
    Declare @BBB table (tstyl char(16),tcont int) Insert @BBB (tstyl,tcont) 
    select xsstyl,count(*) from xlstyle 
    where xsstyl <> '' group by xsstyl having count(*) >1 select rtstyl=xsstyl from xlstyle where xsstyl <> '' and xspric is null 
    Go