通过输出参数!
create proc up_GetTopicList
@a_intForumID int ,
@a_intPageNo int ,
@a_intPageSize int ,
@total_item int output
as
create proc up_GetTopicList
@a_intForumID int ,
@a_intPageNo int ,
@a_intPageSize int ,
@total_item int output
as
CREATE PROCEDURE TheorySearch
(
@keyword nvarchar(100),
@int_pagenow int=0,
@int_pagesize int=0,
@int_recordcount int output
)AS
set nocount ondeclare @int_allid int
declare @int_beginid int,@int_endid int
declare @int_pagebegin int, @int_pageend intselect @int_allid=count(*) from 医学理论 where (题目 like @keyword or 关键词 like @keyword)
set @int_recordcount=@int_allidif @int_recordcount=0
return 0select @int_beginid=(@int_pagenow-1)*@int_pagesize+1
select @int_endid = @int_beginid+@int_pagesize-1 select identity(int,1,1) as id1 ,id+0 as id into #temp from 医学理论 where 题目 like @keyword or 关键词 like @keyword order by id descselect @int_recordcount=@@rowcount
select 题目,文件名,书名,所属章节 from 医学理论 a INNER JOIN #temp b on a.id=b.id and b.id1 between @int_beginid and @int_endid
drop table #tempGO
ASP页面中调用
set cmd=server.CreateObject("adodb.command")
cmd.ActiveConnection=Conn
cmd.CommandType=4
cmd.CommandText="TheorySearch"
set p1=cmd.CreateParameter("keyword",128,1,100,"%"&keyword&"%")
cmd.Parameters.Append p1
set p1=cmd.CreateParameter("int_pagenow",3,1,5,curPage)
cmd.Parameters.append p1
set p1=cmd.CreateParameter("int_pagesize",3,1,5,pagesize)
cmd.parameters.append p1
set p1=cmd.CreateParameter("@int_recordcount",3,2)
cmd.parameters.append p1
set rst=cmd.Execute
if rst.eof then %><!--#include virtual="/public/public00301.htm"-->
<% response.end
end if
dim arrRs
arrRs=rst.getrows
counts= cmd.Parameters("@int_recordcount")
' response.write counts
rst.close
@a_intForumID int ,
@a_intPageNo int ,
@a_intPageSize int ,
@rowcount int output ---------加的
as
/*定义局部变量*/
declare @intBeginID int
declare @intEndID int
declare @intRootRecordCount int
declare @intPageCount int
declare @intRowCount int
/*关闭计数*/
set nocount on/*检测是否有这个版面*/
if not exists(select * from forum where id = @a_intForumID)
return (-1)/*求总共根贴数*/
select @intRootRecordCount = count(*) from bbs where fatherid=0 and forumid=@a_intForumID
if (@intRootRecordCount = 0) --如果没有贴子,则返回零
return 0/*判断页数是否正确*/
if (@a_intPageNo - 1) * @a_intPageSize > @intRootRecordCount
return (-1)/*求开始rootID*/
set @intRowCount = (@a_intPageNo - 1) * @a_intPageSize + 1
/*限制条数*/
set rowcount @intRowCount
select @intBeginID = rootid from bbs where fatherid=0 and forumid=@a_intForumID
order by id desc/*结束rootID*/
set @intRowCount = @a_intPageNo * @a_intPageSize
/*限制条数*/
set rowcount @intRowCount
select @intEndID = rootid from bbs where fatherid=0 and forumid=@a_intForumID
order by id desc/*恢复系统变量*/
set rowcount 0
set nocount off select a.id , a.layer , a.forumid , a.subject , a.faceid , a.hits , a.time , a.UserID , a.fatherid , a.rootid ,
'Bytes' = datalength(a.content) , b.UserName , b.Email , b.HomePage , b.Signature , b.Point
from bbs as a join BBSUser as b on a.UserID = b.ID
where Forumid=@a_intForumID and a.rootid between @intEndID and @intBeginID
order by a.rootid desc , a.ordernum desc
set @rowcount=@@rowcount ---这里改了
go
set objCmd = server.createobject("adodb.command")
objCmd.CommandText = "sp_yoursp"
objCmd.CommandType = adCmdStoredProc
objCmd.ActiveConnection = objConn '--数据库连接对象
objCmd.Parameters.Refresh
'--假定有两个参数,参数2为output
objCmd(1)=x
objCmd.Execute
response.write objCmd(2) '--直接使用objCmd(2)即可
With comm
.ActiveConnection=conn
.CommandText="lc_add"
.CommandType=adCmdStoredProc
.Parameters.Append .CreateParameter("@return_value",adInteger,adParamReturnValue )
.Parameters.Append .CreateParameter("@fieldlist",advarchar,adParamInput,300,fieldlist)
.Parameters.Append .CreateParameter("@valuelist",advarchar,adParamInput,4000,valuelist)
.Parameters.Append .CreateParameter("@id",adInteger,adParamInput,5,ID)
.Execute()
End With
changehouse=comm("@return_value")
response.Write changehouse
set comm=nothing