as
select * from tba
select * from tbb
select * from tbc
select * from tbd
怎么才能只返回
select * from tbd
的结果
18 个解决方案
#1
CREATE PROCEDURE lyg_getArticleClass
as
set nocount on
select * from tba
select * from tbb
select * from tbc
set nocount off
select * from tbd
go
as
set nocount on
select * from tba
select * from tbb
select * from tbc
set nocount off
select * from tbd
go
#2
CREATE PROCEDURE lyg_getArticleClass
@pid int=0
AS
declare @tmp1 table (TC_Id int,TC_PID int,TC_Name varchar(200),lev int,idpath varchar(6000))
declare @lev int
set @lev=1
insert @tmp1 select id,pid,name,1,cast(id as varchar(6000)) from article_classes where pid=0
while @@rowcount>0
begin
set @lev=@lev+1
insert @tmp1 select a.id ,a.pid,a.name,@lev,idpath+','+cast(a.id as varchar(6000)) from article_classes a,@tmp1 b where a.pid=b.tc_ID and a.ID not in (select tc_ID from @tmp1) order by paixuid
end
select * from @tmp1 order by idpath
GO
asp中调用的时候怎么没返回结果呢?
set rs=conn.execute ("execute lyg_getArticleClass 0")
do while not rs.eof//执行这里的时候错误
提示
“对象关闭时不允许操作”
@pid int=0
AS
declare @tmp1 table (TC_Id int,TC_PID int,TC_Name varchar(200),lev int,idpath varchar(6000))
declare @lev int
set @lev=1
insert @tmp1 select id,pid,name,1,cast(id as varchar(6000)) from article_classes where pid=0
while @@rowcount>0
begin
set @lev=@lev+1
insert @tmp1 select a.id ,a.pid,a.name,@lev,idpath+','+cast(a.id as varchar(6000)) from article_classes a,@tmp1 b where a.pid=b.tc_ID and a.ID not in (select tc_ID from @tmp1) order by paixuid
end
select * from @tmp1 order by idpath
GO
asp中调用的时候怎么没返回结果呢?
set rs=conn.execute ("execute lyg_getArticleClass 0")
do while not rs.eof//执行这里的时候错误
提示
“对象关闭时不允许操作”
#3
这和SQL没关系,应该是你ASP调用有问题
#4
ASP没问题,我试过了,把上面的存储过程直接改为:
CREATE PROCEDURE lyg_getArticleClass
@pid int=0
AS
select * from article_tree order by idpath
GO
在ASP中执行就没有问题
CREATE PROCEDURE lyg_getArticleClass
@pid int=0
AS
select * from article_tree order by idpath
GO
在ASP中执行就没有问题
#5
set Rs=conn.execute ("execute lyg_getArticleClass 0")'取第一个记录集
set Rs=Rs.NextRecordset '取第二个记录集
set Rs=Rs.NextRecordset '取第三个记录集
set Rs=Rs.NextRecordset '取第四个记录集
set Rs=Rs.NextRecordset '取第二个记录集
set Rs=Rs.NextRecordset '取第三个记录集
set Rs=Rs.NextRecordset '取第四个记录集
#6
--改改ASP试试
set rs=conn.execute ("execute lyg_getArticleClass 0")
do while not rs.eof//执行这里的时候错误
--------------------------------------------------
dim oComm,oPara
Set oComm = Server.CreateObject("ADODB.Command")
oComm.ActiveConnection = conn
oComm.CommandText = "lyg_getArticleClass"
oComm.CommandType = 4
oComm.Prepared = true
Set oPara = oComm.CreateParameter("pid",3,1)
oComm.Parameters.Append oPara
oComm(0)=0
set rs=oComm.Execute
set oPara=nothing
Set oComm = Nothing
do while not rs.eof
...
...
...
set rs=conn.execute ("execute lyg_getArticleClass 0")
do while not rs.eof//执行这里的时候错误
--------------------------------------------------
dim oComm,oPara
Set oComm = Server.CreateObject("ADODB.Command")
oComm.ActiveConnection = conn
oComm.CommandText = "lyg_getArticleClass"
oComm.CommandType = 4
oComm.Prepared = true
Set oPara = oComm.CreateParameter("pid",3,1)
oComm.Parameters.Append oPara
oComm(0)=0
set rs=oComm.Execute
set oPara=nothing
Set oComm = Nothing
do while not rs.eof
...
...
...
#7
我想应该是你的两个存储过程中前一个在过程中用到了参数,后一个只是声明了没有用到参数,所以测试的结果不能说明你的ASP没问题
#8
也不是参数的问题,调用不调用参数都一样,都取不到结果
#9
set rs=conn.execute ("lyg_getArticleClass")
set rs=rs.nextrecordset
set rs=rs.nextrecordset
set rs=rs.nextrecordset
set rs=rs.nextrecordset
set rs=rs.nextrecordset
晕,我写了5个nextrecordset才可以了。
什么原因
有没有好的办法直接返回记录集,不用这么多nextrecordset
set rs=rs.nextrecordset
set rs=rs.nextrecordset
set rs=rs.nextrecordset
set rs=rs.nextrecordset
set rs=rs.nextrecordset
晕,我写了5个nextrecordset才可以了。
什么原因
有没有好的办法直接返回记录集,不用这么多nextrecordset
#10
前面的结果集既然没有用,不如改改存储过程吧.
#11
难道就没有一个语句可以把前面的结果清除掉
只返回最后一个SELECT的结果吗?
只返回最后一个SELECT的结果吗?
#12
前面为什么有这么多查询阿?
#13
越说越离谱了,你依次执行查询,当然是最后一个了!
#14
最主要一句是set nocount on
把不需要返回的查询结果不显示
把不需要返回的查询结果不显示
#15
楼主结贴吧!
#16
既然前面几个select的结果集都没用的上的话,那你还不如把你的存储过程改为
create procedure pro
as
begin
select * from tbd
end
算了,
create procedure pro
as
begin
select * from tbd
end
算了,
#17
学习了
#18
还是二楼的代码是正确的,我测试的时候漏写了一句
#1
CREATE PROCEDURE lyg_getArticleClass
as
set nocount on
select * from tba
select * from tbb
select * from tbc
set nocount off
select * from tbd
go
as
set nocount on
select * from tba
select * from tbb
select * from tbc
set nocount off
select * from tbd
go
#2
CREATE PROCEDURE lyg_getArticleClass
@pid int=0
AS
declare @tmp1 table (TC_Id int,TC_PID int,TC_Name varchar(200),lev int,idpath varchar(6000))
declare @lev int
set @lev=1
insert @tmp1 select id,pid,name,1,cast(id as varchar(6000)) from article_classes where pid=0
while @@rowcount>0
begin
set @lev=@lev+1
insert @tmp1 select a.id ,a.pid,a.name,@lev,idpath+','+cast(a.id as varchar(6000)) from article_classes a,@tmp1 b where a.pid=b.tc_ID and a.ID not in (select tc_ID from @tmp1) order by paixuid
end
select * from @tmp1 order by idpath
GO
asp中调用的时候怎么没返回结果呢?
set rs=conn.execute ("execute lyg_getArticleClass 0")
do while not rs.eof//执行这里的时候错误
提示
“对象关闭时不允许操作”
@pid int=0
AS
declare @tmp1 table (TC_Id int,TC_PID int,TC_Name varchar(200),lev int,idpath varchar(6000))
declare @lev int
set @lev=1
insert @tmp1 select id,pid,name,1,cast(id as varchar(6000)) from article_classes where pid=0
while @@rowcount>0
begin
set @lev=@lev+1
insert @tmp1 select a.id ,a.pid,a.name,@lev,idpath+','+cast(a.id as varchar(6000)) from article_classes a,@tmp1 b where a.pid=b.tc_ID and a.ID not in (select tc_ID from @tmp1) order by paixuid
end
select * from @tmp1 order by idpath
GO
asp中调用的时候怎么没返回结果呢?
set rs=conn.execute ("execute lyg_getArticleClass 0")
do while not rs.eof//执行这里的时候错误
提示
“对象关闭时不允许操作”
#3
这和SQL没关系,应该是你ASP调用有问题
#4
ASP没问题,我试过了,把上面的存储过程直接改为:
CREATE PROCEDURE lyg_getArticleClass
@pid int=0
AS
select * from article_tree order by idpath
GO
在ASP中执行就没有问题
CREATE PROCEDURE lyg_getArticleClass
@pid int=0
AS
select * from article_tree order by idpath
GO
在ASP中执行就没有问题
#5
set Rs=conn.execute ("execute lyg_getArticleClass 0")'取第一个记录集
set Rs=Rs.NextRecordset '取第二个记录集
set Rs=Rs.NextRecordset '取第三个记录集
set Rs=Rs.NextRecordset '取第四个记录集
set Rs=Rs.NextRecordset '取第二个记录集
set Rs=Rs.NextRecordset '取第三个记录集
set Rs=Rs.NextRecordset '取第四个记录集
#6
--改改ASP试试
set rs=conn.execute ("execute lyg_getArticleClass 0")
do while not rs.eof//执行这里的时候错误
--------------------------------------------------
dim oComm,oPara
Set oComm = Server.CreateObject("ADODB.Command")
oComm.ActiveConnection = conn
oComm.CommandText = "lyg_getArticleClass"
oComm.CommandType = 4
oComm.Prepared = true
Set oPara = oComm.CreateParameter("pid",3,1)
oComm.Parameters.Append oPara
oComm(0)=0
set rs=oComm.Execute
set oPara=nothing
Set oComm = Nothing
do while not rs.eof
...
...
...
set rs=conn.execute ("execute lyg_getArticleClass 0")
do while not rs.eof//执行这里的时候错误
--------------------------------------------------
dim oComm,oPara
Set oComm = Server.CreateObject("ADODB.Command")
oComm.ActiveConnection = conn
oComm.CommandText = "lyg_getArticleClass"
oComm.CommandType = 4
oComm.Prepared = true
Set oPara = oComm.CreateParameter("pid",3,1)
oComm.Parameters.Append oPara
oComm(0)=0
set rs=oComm.Execute
set oPara=nothing
Set oComm = Nothing
do while not rs.eof
...
...
...
#7
我想应该是你的两个存储过程中前一个在过程中用到了参数,后一个只是声明了没有用到参数,所以测试的结果不能说明你的ASP没问题
#8
也不是参数的问题,调用不调用参数都一样,都取不到结果
#9
set rs=conn.execute ("lyg_getArticleClass")
set rs=rs.nextrecordset
set rs=rs.nextrecordset
set rs=rs.nextrecordset
set rs=rs.nextrecordset
set rs=rs.nextrecordset
晕,我写了5个nextrecordset才可以了。
什么原因
有没有好的办法直接返回记录集,不用这么多nextrecordset
set rs=rs.nextrecordset
set rs=rs.nextrecordset
set rs=rs.nextrecordset
set rs=rs.nextrecordset
set rs=rs.nextrecordset
晕,我写了5个nextrecordset才可以了。
什么原因
有没有好的办法直接返回记录集,不用这么多nextrecordset
#10
前面的结果集既然没有用,不如改改存储过程吧.
#11
难道就没有一个语句可以把前面的结果清除掉
只返回最后一个SELECT的结果吗?
只返回最后一个SELECT的结果吗?
#12
前面为什么有这么多查询阿?
#13
越说越离谱了,你依次执行查询,当然是最后一个了!
#14
最主要一句是set nocount on
把不需要返回的查询结果不显示
把不需要返回的查询结果不显示
#15
楼主结贴吧!
#16
既然前面几个select的结果集都没用的上的话,那你还不如把你的存储过程改为
create procedure pro
as
begin
select * from tbd
end
算了,
create procedure pro
as
begin
select * from tbd
end
算了,
#17
学习了
#18
还是二楼的代码是正确的,我测试的时候漏写了一句