下面是存储过程分页 ASP调用部分的代码,请问怎样写查询条件,这里的默认是 " ",也就是默认把所有的记录都列举出来了.
就是下面那个 CmdSp( "@condition ")= " "该怎么写?
我换了很多方式,都出错,请指点,谢谢!
<%
dim records
page=request( "page ")
if not isnumeric(page) then
page=1
end if
if page <1 then
page=1
end if
set rs=server.createobject( "adodb.recordset ")
Set CmdSP = Server.CreateObject( "ADODB.Command ")
CmdSP.ActiveConnection = connstr 'MyConStr是数据库连接字串
CmdSP.CommandText = "sp_newpage " '指定存储过程名
CmdSP.CommandType = 4 '表明这是一个存储过程
CmdSP.Prepared = true '要求将SQL命令先行编译
'返回值
CmdSp.Parameters.Append CmdSp.CreateParameter( "RETURN_VALUE ",adInteger,adParamReturnValue,4)
'入参(表名)
CmdSp.Parameters.Append CmdSp.CreateParameter( "@tb ",adVarChar,adParamInput,50)
'入参(按该列来进行分页)
CmdSp.Parameters.Append CmdSp.CreateParameter( "@col ",adVarChar,adParamInput,50)
'入参(col列的类型,0-数字类型,1-字符类型,2-日期时间类型)
CmdSp.Parameters.Append CmdSp.CreateParameter( "@coltype ",adInteger,adParamInput)
'入参(排序,0-顺序,1-倒序)
CmdSp.Parameters.Append CmdSp.CreateParameter( "@orderby ",adInteger,adParamInput)
'入参(要查询出的字段列表,*表示全部字段)
CmdSp.Parameters.Append CmdSp.CreateParameter( "@collist ",adVarChar,adParamInput,800)
'入参(每页记录数)
CmdSp.Parameters.Append CmdSp.CreateParameter( "@pagesize ",adInteger,adParamInput)
'入参(指定页)
CmdSp.Parameters.Append CmdSp.CreateParameter( "@page ",adInteger,adParamInput)
'入参(查询条件)
CmdSp.Parameters.Append CmdSp.CreateParameter( "@condition ",adVarChar,adParamInput,800)
'出参(总记录数)
CmdSp.Parameters.Append CmdSp.CreateParameter( "@RecordCount ",adInteger,adParamOutput)
'出参(总页数)
CmdSp.Parameters.Append CmdSp.CreateParameter( "@pages ",adInteger,adParamOutput)
CmdSp( "@tb ")= "title "
'上面是你的表名
CmdSp( "@col ")= "id "
'上面是表的ID
CmdSp( "@coltype ")=0
CmdSp( "@orderby ")=0
CmdSp( "@collist ")= "* "
CmdSp( "@pagesize ")=10
CmdSp( "@page ")=page
strSql= "where id> 40 "
CmdSp( "@condition ")= " "
Set rs =CmdSp.Execute