执行存储过程带参数,分页的功能就不能用了,为什么?
****错误信息:
ADODB.Recordset (0x800A0CB3)
Current Recordset does not support bookmarks. This may be a limitation of the provider or of the selected cursortype.
****存储过程:
是有参数的
****asp中调用代码:
strQuery = "exec sp_test '"&request("aa")&"','"&request("bb")&"','"&request("cc")&"','"&request("dd")&"'"
dim iPageCount,iCurPage,iRow,iRec
iRec = (p-1)*iRow+1
set Rs = server.CreateObject("ADODB.RECORDSET")'****************出错位置
Rs.Open strQuery,Conn2,3,1
if rs.eof then response.end
rs.pagesize=iRow
rs.absolutepage=p '****************可能出错原因
iCount=Rs.RecordCount
Rs.CacheSize=iRow
****疑惑:
1。不带参数的存储过程就可正常运行
2。用调用存储过程的方法调用也不行
dim iPageCount,iCurPage,iRow,iRec
iRec = (p-1)*iRow+1
' strQuery = "select top 50 * from transactions " & strWhere & " order by transtime desc"
'response.write strQuery & "<br>"
'这些值在 VB 中是预定义常量
'建一个command对象
set CmdSP = Server.CreateObject("ADODB.Command")
'建立连结
CmdSP.ActiveConnection = Conn2
'定义command 对象调用名称
CmdSP.CommandText = strQuery
'设置command调用类型是存储过程 (adCmdSPStoredProc = 4)
CmdSP.CommandType = adCmdSPStoredProc
'往command 对象中加参数
'定义存储过程有直接返回值,并且是个整数,省缺值是4
CmdSP.Parameters.Append CmdSP.CreateParameter("@retailer", adVarChar, adParamInput, 16,outlet)
'CmdSP.Parameters.Append CmdSP.CreateParameter("@branch", adVarChar, adParamInput, 15,branch)
'CmdSP.Parameters.Append CmdSP.CreateParameter("@starttime", adVarChar, adParamInput, 30,transdate_low)
'CmdSP.Parameters.Append CmdSP.CreateParameter("@endtime", adVarChar, adParamInput, 30,transdate_high)
'然后生成记录集
Set rs = CmdSp.Execute
'set Rs = server.CreateObject("ADODB.RECORDSET")
'Rs.Open strQuery,Conn2,3,1
if rs.eof then response.end
rs.pagesize=iRow
rs.absolutepage=p
iCount=Rs.RecordCount
Rs.CacheSize=iRow