为什么作OleDbDataAdapter.Fill( DataTable )时,我取不到返回的记录集?
CommondText = "EXEC get_set";
存储过程如下:
CREATE proc get_set
as
declare @tmp1 table (ID varchar(20),NAME varchar(400),KEYWORD varchar(50),TITLE varchar(400),CONTENT varchar(4000),PARENT_ID varchar(20))
insert @tmp1 select id,name,keyword,title,content,parent_id from t_qa where ID='00000009'
while exists(select 1 from t_qa a,@tmp1 b where a.parent_id=b.id and a.ID not in (select ID from @tmp1))
insert @tmp1 select a.id,a.name,a.keyword,a.title,a.content,a.parent_id from t_qa a,@tmp1 b where a.parent_id=b.ID and a.ID not in (select ID from @tmp1)
select * from @tmp1
GO
此存储过程在查询分析器中可以取的结果集!
存储过程如下:
CREATE proc get_set
as
declare @tmp1 table (ID varchar(20),NAME varchar(400),KEYWORD varchar(50),TITLE varchar(400),CONTENT varchar(4000),PARENT_ID varchar(20))
insert @tmp1 select id,name,keyword,title,content,parent_id from t_qa where ID='00000009'
while exists(select 1 from t_qa a,@tmp1 b where a.parent_id=b.id and a.ID not in (select ID from @tmp1))
insert @tmp1 select a.id,a.name,a.keyword,a.title,a.content,a.parent_id from t_qa a,@tmp1 b where a.parent_id=b.ID and a.ID not in (select ID from @tmp1)
select * from @tmp1
GO
此存储过程在查询分析器中可以取的结果集!
...全文
请发表友善的回复…
发表回复
yanransoft 2004-08-09
- 打赏
- 举报
SqlCommand.CommandType=StoredProcedure;
luysh 2004-08-09
- 打赏
- 举报
更正:即便是把最后的“select * from @tmp1”
改成“select * from t_qa”,也不能返回结果集
除非:
注释掉存储过程中的以下三行
insert @tmp1 select id,name,keyword,title,content,parent_id from t_qa where ID='00000009'
while exists(select 1 from t_qa a,@tmp1 b where a.parent_id=b.id and a.ID not in (select ID from @tmp1))
insert @tmp1 select a.id,a.name,a.keyword,a.title,a.content,a.parent_id from t_qa a,@tmp1 b where a.parent_id=b.ID and a.ID not in (select ID from @tmp1)
改成“select * from t_qa”,也不能返回结果集
除非:
注释掉存储过程中的以下三行
insert @tmp1 select id,name,keyword,title,content,parent_id from t_qa where ID='00000009'
while exists(select 1 from t_qa a,@tmp1 b where a.parent_id=b.id and a.ID not in (select ID from @tmp1))
insert @tmp1 select a.id,a.name,a.keyword,a.title,a.content,a.parent_id from t_qa a,@tmp1 b where a.parent_id=b.ID and a.ID not in (select ID from @tmp1)
luysh 2004-08-09
- 打赏
- 举报
如果存储过程最后是从表中取值则没有问题
即:
最后“select * from @tmp1”
改成“select * from t_qa”
即:
最后“select * from @tmp1”
改成“select * from t_qa”
sy246 2004-08-09
- 打赏
- 举报
不应该是你的存储过程的问题呀!