打印

[asp] 叶子分页中,取得总数有些不明,知的朋友解答一下.

复制内容到剪贴板
代码:
    Public Property Get RecordCount()
        If iRecType>0 Then
            i=iRecType
        Elseif iRecType=0 Then
            i=CheckNum(Request.Cookies("ShowoPage")(sPageName),1,0,0,0)
            s=Trim(Request.Cookies("ShowoPage")("sCond"))
            IF i=0 OR sCondition<>s Then
                [color=Red]i=oConn.Execute("SELECT COUNT(" & sPKey & ") FROM " & sTable & " " & sCondition,0,1)(0)
                Response.Cookies("ShowoPage")(sPageName)=i
                Response.Cookies("ShowoPage")("sCond")=sCondition[/color]            End If
        Else
            [color=Red]i=oConn.Execute("SELECT COUNT(" & sPKey & ") FROM " & sTable & " " & sCondition,0,1)(0)[/color]
        End If
        iRecordCount=i
        RecordCount=i
    End Property
i=oConn.Execute("SELECT COUNT(" & sPKey & ") FROM " & sTable & " " & sCondition,0,1)(0)
                            Response.Cookies("ShowoPage")(sPageName)=i
                            Response.Cookies("ShowoPage")("sCond")=sCondition



这里用到response.cookies有什么用?



oConn.Execute("SELECT COUNT(" & sPKey & ") FROM " & sTable & " " & sCondition,0,1)(0)

这句的后面几个值是什么意思?   去掉就执行不了了?

TOP

保存到cookies中就不需要一次次select了。也可以保存到session中。
oConn.Execute("SELECT COUNT(" & sPKey & ") FROM " & sTable & " " & sCondition,0,1)(0)
举个实际点的:
conn.Execute("select count("id") from table")(0)这个(0)同conn.Execute("select count("id") from table")("id")
也就是rs("id")=rs(0)
乐于助人、严格管理、言多必失。无知者无罪。
编程资源:http://book.kuhanzhu.com

TOP

保存到session或者cookie是不是相当于一个全局变量?

TOP

恩,,

TOP

是的,,

TOP