存储过程返回数据了,但为什么我取不出output的值返回select了
这是调用存储过程的代码
******************************************
Return_intRecordCount = objCommand.Parameters("int_recordcount")返回值为0但在查询分析器里print 出来是正确的返回数
怎么回事?
With objCommand
.ActiveConnection = BizComConnstr
.CommandType = adCmdStoredProc
.CommandText = "Trade_PageView"
.Parameters.Append .CreateParameter("int_AgentID", adInteger, adParamInput, , CurrencyAgentID) '代理ID
.Parameters.Append .CreateParameter("int_AccountID", adInteger, adParamInput, , CurrencyAccoutID) '用户ID
.Parameters.Append .CreateParameter("int_pagenow", adInteger, adParamInput, , Page) '当前页面
.Parameters.Append .CreateParameter("int_pagesize", adInteger, adParamInput, , intPageSize) '分页记录数
.Parameters.Append .CreateParameter("int_ClassID", adInteger, adParamInput, , ClassID) '类别ID
.Parameters.Append .CreateParameter("str_KeyWord", adVarChar, adParamInput, 30, KeyWord) '关键字
.Parameters.Append .CreateParameter("int_recordcount", adInteger, adParamOutput)
End With
Set Rs = objCommand.Execute
If Err.Number <> 0 Then
Return_intRecordCount = 0
ErrTxt = "Execute the storeproc error.The Err description:" & Err.Description
Set Rs = Nothing
objCommand.ActiveConnection.Close
Set objCommand = Nothing
Exit Function
End If
If Rs.EOF Then
ErrTxt = "没有供求信息"
Set Rs = Nothing
objCommand.ActiveConnection.Close
Set objCommand = Nothing
'Set Return_arrFields = Nothing
Return_intRecordCount = 0
OfferManage = True
Exit Function
Else
Return_arrFields = Rs.GetRows
Return_intRecordCount = objCommand.Parameters("int_recordcount")
strLinkUrl = Request.ServerVariables("SCRIPT_NAME") & "?KeyWord=" & KeyWord & "&CategoryID=" & ClassID & "&"
strSplitPage = ExportPageInfo(Return_intRecordCount, intPageSize, Page, strLinkUrl, 3, "RedFnt")
Response.Write("记录总数:" & Return_intRecordCount)'为什么输出会为0呢
Set Rs = Nothing
objCommand.ActiveConnection.Close
Set objCommand = Nothing
OfferManage = True
End If
以下是存储过程代码
ALTER PROCEDURE dbo.Trade_PageView
--WITH ENCRYPTION
(
@int_AgentID int=0,--代理ID
@int_AccountID int=0,--用户ID
@int_pagenow int=1,--当前页面
@int_pagesize int=20,--页面大小
@int_ClassID int=0,--大类别编号
-- @int_IsExp int=0,--是否过期 0:全部,1:为已过期,2:未过期
@str_KeyWord nvarchar(30),--关键字
@int_recordcount int = 0 output--这是输出的值
)
AS
set nocount on
declare @int_allid int
declare @int_beginid int
declare @int_endid int
declare @str_SqlWhere varchar(500)
declare @str_SqlStr nvarchar(2000)
declare @int_pagebegin int
declare @int_pageend int
declare @str_IDStr nvarchar(500)
declare @str_tmpStr nvarchar(500)
select @str_SqlWhere = ''
--处理开始
--处理代理
if (ISNUMERIC(@int_AgentID)=1 and @int_AgentID>0)
begin
select @str_SqlWhere = @str_SqlWhere + ' AND (AgentID = ' + cast(@int_AgentID as varchar) + ')'
End
--处理用户
if (ISNUMERIC(@int_AccountID)=1 and @int_AccountID>0)
begin
select @str_SqlWhere = @str_SqlWhere + ' AND (AccountID = ' + cast(@int_AccountID as varchar) + ')'
End
--处理类别
if (ISNUMERIC(@int_ClassID)=1 and @int_ClassID>0)--是否有类别
begin
select @str_SqlWhere = @str_SqlWhere + ' AND (BigClassID = ' + cast(@int_ClassID as varchar) + ')'
End
--处理关键字
if (@str_KeyWord<>'' and @str_KeyWord is not null)
begin
select @str_KeyWord = '%' + @str_KeyWord + '%'
select @str_SqlWhere = @str_SqlWhere + ' AND ((TradeTitle like ''' + @str_KeyWord + ''') or (TradeKeyword like ''' + @str_KeyWord + '''))'
End
--取得查询总记录数
select @str_tmpStr = N'select @int_allid=count(TradeID) from LXBIZ_Trade where (1=1)' + @str_SqlWhere
exec sp_executesql @str_tmpStr,N'@int_allid int out',@int_allid out
--取得分页第一条记录的编号
select @str_tmpStr = N'SELECT @int_allid=TradeID FROM LXBIZ_Trade where (1=1)' + @str_SqlWhere + ' ORDER BY TradeID DESC'
if (@int_pagenow-1)*@int_pagesize>@int_allid
begin
select @int_pagenow=1
end
select @int_beginid=(@int_pagenow-1)* @int_pagesize +1
set rowcount @int_beginid --定位ID
exec sp_executesql @str_tmpStr,N'@int_allid int out ',@int_pagebegin out
--取得分页最后一条记录的编号
select @int_endid = @int_beginid + @int_pagesize -1
set rowcount @int_endid --定位ID
exec sp_executesql @str_tmpStr,N'@int_allid int out ',@int_pageend out
------恢复系统设置-----
select @int_recordcount = @int_allid
set rowcount 0
SET NOCOUNT OFF
If (@int_pagebegin is not null) and (@int_pageend is not null)
begin
select @str_IDStr=' AND (TradeID between '+ cast(@int_pageend as varchar) + ' and ' + cast(@int_pagebegin as varchar) + ') '
end
else
begin
select @str_IDStr=''
end
if (@str_SqlWhere<>'' and @str_SqlWhere is not null)
begin
select @str_SqlStr ='SELECT AgentID, AgentName,TradeID, AccountID, CompanyName, TradeTitle, TypeID, BigClassID, BigClassName, SubClassID, SubClassName, EndClassID, EndClassName, TradePic,TradeExpireDate, TradeHits, TradeFlag, InfoLevel, IssueTime FROM LXBIZ_Trade where (1=1) ' + @str_IDStr + @str_SqlWhere + ' ORDER BY TradeID DESC'
end
else
begin
select @str_SqlStr ='SELECT AgentID, AgentName,TradeID, AccountID, CompanyName, TradeTitle, TypeID, BigClassID, BigClassName, SubClassID, SubClassName, EndClassID, EndClassName, TradePic,TradeExpireDate, TradeHits, TradeFlag, InfoLevel, IssueTime FROM LXBIZ_Trade where (1=1) ' + @str_IDStr + ' ORDER BY TradeID DESC'
end
exec(@str_SqlStr)
return