XDownPage2.10 simple example (sqlserver)

Source: Internet
Author: User
Asp paging basic class XDownPage2.0 only supports oracle, while 2.10 already supports sqlserver. This example shows the XDownPage2.10 paging Method for sqlserver databases. 1. for paging program code, see blog. csdn. netprecipitantarchive200611151386541.aspx2, conn. asp.

Asp paging basic class XDownPage2.0 only supports oracle, while 2.10 already supports sqlserver. This example shows the XDownPage2.10 paging Method for sqlserver databases. 1, paging program code please refer to another article: http://blog.csdn.net/precipitant/archive/2006/11/15/1386541.aspx 2, conn. asp

Asp paging basic class XDownPage2.0 only supports oracle, while 2.10 already supports sqlserver. This example shows the XDownPage2.10 paging Method for sqlserver databases.

1. Paging program code

Please refer to another article: http://blog.csdn.net/precipitant/archive/2006/11/15/1386541.aspx

2. conn. asp (database connection related Program)

'================================================ ==============
'Database access
'================================================ ==============

'Establish a database connection
Dim conn' database connection object
Set conn = server. createobject ("ADODB. CONNECTION ")
Sub openConn
Connstr = "Provider = sqloledb; Data Source = 127.0.0.1; Initial Catalog = it; User Id = it_manage; Password = it_manage ;"
Conn. open connstr
End sub
'Clear database connection
Sub CloseConn
Conn. Close ()
Set conn = nothing
End sub

'Close the enabled record set
Sub CloseRS (byref recordset)
Recordset. close ()
Set recordset = nothing
End sub

'Get the name of the current virtual directory
Function getRoot ()
Url = Request. ServerVariables ("URL ")
Url = right (url, len (url)-1)
GetRoot = mid (url, 1, instr (url, "/")-1)
End function

'---------------- Database sorting start ---------------------------
SImageDir = "/" & getRoot () & "/images/" 'image path
UpOrderFlag = "" & sImageDir & "sort_asc.gif '>"' display icons in ascending order
DownOrderFlag = "" & sImageDir & "sort_desc.gif '>" 'display icons in descending order
'Get the sorting direction of the current connection
Function getOrderDir (fn, ofn, oDir)
Dim tDir
TDir = "desc"
If (lcase (fn) = lcase (ofn) then
If (lcase (oDir) = "asc") then
TDir = "desc"
Else
TDir = "asc"
End if
End if
GetOrderDir = tDir
End function

'Writing order indicator icons
Function writeOrderDir (fn, ofn, oDir)
Dim tDir
If (lcase (fn) = lcase (ofn) then
If (lcase (oDir) = "asc") then
TDir = UpOrderFlag
Else
TDir = downOrderFlag
End if
End if
WriteOrderDir = tDir
End function

'Add the sorting column headers
Sub WriteOrderHeader (pHeaderTitle, pOrderField, tOrderField, tOrderDir)
Response. write "" & pOrderField & "','" & getOrderDir (pOrderField, tOrderField, tOrderDir) & "" class = 'noticetitle' style = 'width: 90%; cursor: default '> "& pHeaderTitle &" "& writeOrderDir (pOrderField, tOrderField, tOrderDir )&""
End sub

'---------------- Database sorting end ---------------------------

3, main. asp (main Program)



<%...
'Fault Category Management
'Writer: northsnow
'Create date: 051211
%>

<%... 'On error resume next
'Get Parameters
Dim err_type_name, err_type_code
Dim currentpage, flag, pagesize, rsTotalCount, orderDir, orderField
Currentpage = trim (request. form ("currentpage "))
P_p = trim (request ("p_p "))
Flag = trim (request ("flag "))
Pagesize = trim (request ("pagesize "))
RsTotalCount = trim (request ("rsTotalCount "))
OrderDir = trim (Request ("orderdir "))
OrderField = trim (Request ("orderfield "))

Err_type_code = trim (request ("err_type_code "))
Err_type_name = trim (request ("err_type_name "))
%>

> Fault category management




Query |
Reset











Category Code:
Category name:

































<%... 'Define record set objectSet rs = server. CreateObject ("adodb. recordset ")Rs. CursorLocation = 3' defines the record set attributesIf pagesize = "" then pagesize = 15' defines the size of the lifecycle page. '// Form a query condition stringStrOption = "where 1 = 1"If err_type_code <> "thenStrOption = strOption & "and err_type_code = '" & err_type_code &"'"End ifIf err_type_name <> "" thenStrOption = strOption & "and err_type_name like '%" & err_type_name & "% '"End if'Form the sorting stringStrOrder = ""If orderField <> "" thenStrOrder = "order by" & orderFieldIf orderDir <> "" then strOrder = strOrder & "" & orderDirEnd ifIf strOrder = "" then strOrder = "order by err_type_code asc" 'Connect to the databaseCall OpenConn () Set mypage = new xdownpage 'create a paging Class ObjectMypage. getconn = </

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.