rs.PageCount cannot function
am 05.04.2005 03:42:24 von tchangmianCould 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