日期:2014-05-17  浏览次数:20960 次

ASP与存储过程
问题描述:
1。我在存储过程中,用参数代替,可以执行出查询结果
2。我在ASP中执行,没有结果显示,rs_buy.recordcout =-1,conn.state=1

第一次使用这种方法,请教了

ASP的代码如下
dim cmd,rs_buy
Const adCmdStoredProc=4
Set cmd=Server.CreateObject("ADODB.Command")
Set rs_buy=Server.CreateObject("ADODB.Recordset")
With cmd
.ActiveConnection=conn
.CommandText ="a_2012hu_wwworder_list"
.CommandType =4
.Prepared =True
.Parameters.Append .CreateParameter("Fyear",20,1,8,getn)
.Parameters.Append .CreateParameter("Fmonth",20,1,5,gety)
.Parameters.Append .CreateParameter("Fuserid",20,1,20,0)
.Parameters.Append .CreateParameter("Fxsb",20,1,15,getdep)
.Parameters.Append .CreateParameter("Fbsc",20,1,15,getbsc)
.Parameters.Append .CreateParameter("Fcust",20,1,15,nowzu)
Set rs_buy=.Execute
End With

存储过程的代码如下:
ALTER proc [dbo].[a_2012hu_wwworder_list]
@Fyear int,
@Fmonth int,
@Fuserid int,
@Fxsb int,
@Fbsc int,
@Fcustid int
as
SET NOCOUNT ON

--declare @Fyear int
--declare @Fmonth int
--declare @Fuserid int
--declare @Fxsb int
--declare @Fbsc int
--declare @Fcustid int
--set @Fyear=2012
--set @Fmonth=7
--set @Fuserid=0
--set @Fxsb=0
--set @Fbsc=45102
--set @Fcustid=0
CREATE TABLE #tkhb(
[Fcustid] [int] NOT NULL,
[Fname] [varchar](80) NULL,
[F_111] [int] NULL,
[Fbsc] [varchar](20) NOT NULL,
[Fxsb] [varchar](20) NOT NULL,
[F_112] [int] NULL
) ON [PRIMARY]
CREATE TABLE #khb(
[Fcustid] [int] NOT NULL,
[Fname] [varchar](80) NULL,
[F_111] [int] NULL,
[Fbsc] [varchar](20) NOT NULL,
[Fxsb] [varchar](20) NOT NULL,
[F_112] [int] NULL
) ON [PRIMARY]
if @Fcustid=0
-----------------------------------------------
--客户不确定
  begin
  if @Fuserid=0
----------------------------------------------------
---BI用户
  begin
  insert into #tkhb
  (Fcustid,a.Fname,F_111,Fbsc,Fxsb,F_112)
  select a.Fcustid,c.Fname,c.F_111,d.Fname,e.Fname,F_112
  from a_2012hu_wwwkehuentry a
  inner join a_2012hu_wwwkehu b on a.fid=b.fid
  inner join t_organization c on a.Fcustid=c.Fitemid
  inner join t_item d on c.F_111=d.Fitemid
  inner join t_item e on c.F_112=e.Fitemid
  end
----------------------------------------------------
  else
----------------------------------------------------
----非BI用户
  begin
  insert into #tkhb
  (Fcustid,a.Fname,F_111,Fbsc,Fxsb,F_112)
  select a.Fcustid,c.Fname,c.F_111,d.Fname,e.Fname,F_112
  from a_2012hu_wwwkehuentry a
  inner join a_2012hu_wwwkehu b on a.fid=b.fid
  inner join t_organization c on a.Fcustid=c.Fitemid
  inner join t_item d on c.F_111=d.Fitemid
  inner join t_item e on c.F_112=e.Fitemid
  where b.Fuserid=@Fuserid
  end
----------------------------------------------------
  end
----------------------------------------------------

else
----------------------------------------------------
--客户ID不等0
  begin
  insert into #tkhb
  (Fcustid,a.Fname,F_111,Fbsc,Fxsb,F_112)
  select
  a.Fitemid,a.Fname,F_111,b.Fname,c.Fname,F_112
  from t_organization a
  inner join t_item b on a.F_111=b.Fitemid
&n