rs.PageCount cannot function

rs.PageCount cannot function

am 05.04.2005 03:42:24 von tchangmian

Could somebody help me? is urgent.
I failed to get the page count. when i response.write the
strStoredProc.PageCount, it return value -1.
Can somebody tell me that whether
"rstStoredProc.Open objCommand,strConn,adOpenForwardOnly,
adLockReadOnly, adCmdStoredProc" is correct to write in this way?


Call GetConnString(strConn)
Set objCommand = Server.CreateObject("ADODB.Command")
objCommand.ActiveConnection = strConn
objCommand.CommandText = "spDocketPrinting"
objCommand.CommandType = adCmdStoredProc

'response.Write "strSupId=" response.Write strSupId
Set paramId = objCommand.CreateParameter("@strSupId", adVarChar,
adParamInput, 4)
paramId.Value = strSupId
objCommand.Parameters.Append paramId
'response.Write strSupId

'response.Write "strFromDate=" response.Write strFromDate
Set paramId = objCommand.CreateParameter("@strFromDate", adVarChar,
adParamInput,10)
paramId.Value = strFromDate
objCommand.Parameters.Append paramId

Set paramId = objCommand.CreateParameter("@strToDate", adVarChar,
adParamInput,10)
paramId.Value = strToDate
objCommand.Parameters.Append paramId
response.Write strToDate

'response.Write "strProdCode=" response.Write strProdCode
Set paramId = objCommand.CreateParameter("@strProdCode", adVarChar,
adParamInput,20)
paramId.Value = strProdCode
objCommand.Parameters.Append paramId

'response.Write "strProdType=" response.Write strProdType
Set paramId = objCommand.CreateParameter("@strProdType", adVarChar,
adParamInput,20)
paramId.Value = strProdType
objCommand.Parameters.Append paramId
'response.Write strProdType

'response.Write "strStatus=" response.Write strStatus
Set paramId = objCommand.CreateParameter("@strStatus", adVarChar,
adParamInput,20)
paramId.Value = strStatus
objCommand.Parameters.Append paramId
'response.Write strStatus
'response.End
'response.Write "strItemRef=" response.Write strItemRef
Set paramId = objCommand.CreateParameter("@strItemRef", adVarChar,
adParamInput,20)
paramId.Value = strItemRef
objCommand.Parameters.Append paramId

'response.Write "strArea=" response.Write strArea
Set paramId = objCommand.CreateParameter("@strSortBy", adVarChar,
adParamInput,20)
paramId.Value = strSortBy
objCommand.Parameters.Append paramId

'response.Write "strArea=" response.Write strArea
Set paramId = objCommand.CreateParameter("@strArea", adVarChar,
adParamInput,20)
paramId.Value = strArea
objCommand.Parameters.Append paramId

'objCommand.Parameters.Append objCommand.CreateParameter("@Sales",
adVarChar, adParamOutput, 20)
Set rstStoredProc = objCommand.Execute

rstStoredProc.CursorLocation = adUseClient
rstStoredProc.Type = adOpenStatic
rstStoredProc.Open objCommand,strConn,adOpenForwardOnly,
adLockReadOnly, adCmdStoredProc


if Request.QueryString("PageNum") = "" Then
intPageNum = 1
else
intPageNum = Request.QueryString("PageNum")
End if

Dim avarRecord
if(not rstStoredProc.EOF) Then

rstStoredProc.PageSize = intNumRecInPage
intPageCount = rstStoredProc.PageCount
if IntPageCount <= rstStoredProc.PageCount then
rstStoredProc.AbsolutePage = intPageNum
End If

avarRecord = rstStoredProc.GetRows

if Cint(UBound(avarRecord,2)) < CInt(intNumRecInPage) Then
intNumRecReturn = Cint(UBound(avarRecord,2))
Else
intNumRecReturn = CInt(intNumRecInPage) - 1
End If

Re: rs.PageCount cannot function

am 05.04.2005 12:41:55 von reb01501

tchangmian wrote:
> Could somebody help me? is urgent.

I already replied to this question in .asp.general, where you initially
posted it yesterday. If my answer did not solve your problem, at least do me
the courtesy of replying to my post explaining why my answer did not solve
your problem, instead of starting a new thread in another newsgroup.

Bob Barrows
PS. I just remembered something. See this thread: http://tinyurl.com/3cl6e,
then continue reading here.

IMO, this is a bug in the SQLOLEDB provider. Interestingly enough, there is
a similar but different bug in the ODBC driver. When using ODBC with the
tests I performed in that thread, I get these results:

Before open, using stored procedure executed via dynamic sql, cursortype = 3
After open, using stored procedure executed via dynamic sql, cursor type =
3; RecordCount = -1

Before open, using stored procedure executed via
procedure-as-connection-method, cursortype = 3
After open, using stored procedure executed via
procedure-as-connection-method, cursor type = 3; RecordCount = -1

Before open, using stored procedure executed via Command object, cursortype
= 3
After open, using stored procedure executed via Command object, cursor type
= 3; RecordCount = -1

Before open, using dynamic sql, cursortype = 3
After open, using dynamic sql, cursor type = 3; RecordCount = 23

So, even though it's giving us the "right" cursortype, the recordcount is
not known. When I add this line:
"rsTest.Supports(adBookmark)=" & rsTest.Supports(adBookmark)

I discover that the only time bookmarks are supported is when using a
dynamic sql statement to open the recordset, rather than the stored
procedure.

This is not the documented behavior.

Workaround: use a client-side cursor (rs.cursorlocation=3) when opening the
recordset on a procedure, or use a more efficient method of getting the
record count.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"