delphi7 执行存储过程,未返回结果集!在sql的查询分析器里执行有数据结果 10
sql存储过程代码:CREATEPROCEDURE[dbo].[proc_rsj_sel]@selytpeint=0,@fcnovarchar(5)='',@fjnova...
sql存储过程代码:
CREATE PROCEDURE [dbo].[proc_rsj_sel]
@selytpe int=0,
@fcno varchar(5)='',
@fjno varchar(5)='',
@rqs varchar(10)='',
@rqe varchar(10)=''
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON
if(@selytpe=0)
select * from T_RSJ where F_RQ between @rqs and @rqe order by F_RQ
else if(@selytpe=1)
select * from T_RSJ where F_RQ between @rqs and @rqe and F_FC_NO=@fcno order by F_RQ
else if(@selytpe=2)
select * from T_RSJ where F_RQ between @rqs and @rqe and F_FC_NO=@fcno and F_FJ_NO=@fjno order by F_RQ
else
select * from T_RSJ
END
GO
delphi 端代码:
StoreProcRSJ.Parameters.ParamByName('@rqs').Value :=formatdatetime('yyyy-MM-dd',dtp1.Date);
StoreProcRSJ.Parameters.ParamByName('@rqe').Value :=formatdatetime('yyyy-MM-dd',dtp2.Date);
StoreProcRSJ.Parameters.ParamByName('@selytpe').Value := CuNode.Level;
case CuNode.Level of
1:
begin
StoreProcRSJ.Parameters.ParamByName('@fcno').Value := PNodeRec(CuNode.Data).sKey;
end;
2:
begin
StoreProcRSJ.Parameters.ParamByName('@fjno').Value := PNodeRec(CuNode.Data).sKey;
StoreProcRSJ.Parameters.ParamByName('@fcno').Value := PNodeRec(CuNode.Parent.Data).sKey;
end;
end;
StoreProcRSJ.ExecProc;
ADOQuery1.SQL.Add(sqlstr);
ADOQuery1.Open;
Fmain.dqc.Message_Show(inttostr( ADOQuery1.RecordCount));
用这种方法调试发现 还是不行
是不是我的存储过程写的有问题了? 但通过查询分析器执行该存储过程是可以的 展开
CREATE PROCEDURE [dbo].[proc_rsj_sel]
@selytpe int=0,
@fcno varchar(5)='',
@fjno varchar(5)='',
@rqs varchar(10)='',
@rqe varchar(10)=''
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON
if(@selytpe=0)
select * from T_RSJ where F_RQ between @rqs and @rqe order by F_RQ
else if(@selytpe=1)
select * from T_RSJ where F_RQ between @rqs and @rqe and F_FC_NO=@fcno order by F_RQ
else if(@selytpe=2)
select * from T_RSJ where F_RQ between @rqs and @rqe and F_FC_NO=@fcno and F_FJ_NO=@fjno order by F_RQ
else
select * from T_RSJ
END
GO
delphi 端代码:
StoreProcRSJ.Parameters.ParamByName('@rqs').Value :=formatdatetime('yyyy-MM-dd',dtp1.Date);
StoreProcRSJ.Parameters.ParamByName('@rqe').Value :=formatdatetime('yyyy-MM-dd',dtp2.Date);
StoreProcRSJ.Parameters.ParamByName('@selytpe').Value := CuNode.Level;
case CuNode.Level of
1:
begin
StoreProcRSJ.Parameters.ParamByName('@fcno').Value := PNodeRec(CuNode.Data).sKey;
end;
2:
begin
StoreProcRSJ.Parameters.ParamByName('@fjno').Value := PNodeRec(CuNode.Data).sKey;
StoreProcRSJ.Parameters.ParamByName('@fcno').Value := PNodeRec(CuNode.Parent.Data).sKey;
end;
end;
StoreProcRSJ.ExecProc;
ADOQuery1.SQL.Add(sqlstr);
ADOQuery1.Open;
Fmain.dqc.Message_Show(inttostr( ADOQuery1.RecordCount));
用这种方法调试发现 还是不行
是不是我的存储过程写的有问题了? 但通过查询分析器执行该存储过程是可以的 展开
2个回答
2014-07-30 · 知道合伙人软件行家
关注
展开全部
最后一句应该是StoreProcRSJ.open();
.
.
追问
// StoreProcRSJ.ExecProc;
StoreProcRSJ.Open;
Fmain.dqc.Message_Show(inttostr( StoreProcRSJ.RecordCount));
谢谢回答,
open也不行,我调试也不行。 存储过程应该执行成功,就是结果集反回不来
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询