Recommended: Commonly used variable naming rules in ASP In ASP, commonly used variable naming rules. In ASP programming, if you abide by the following variable naming rules, your code will be feasible and maintainable: Examples of general naming rules prefix variable types b or bln Boolean bSuccess c or cur Currency cAmount d or dbl Double dblQuantity dt or dat Date and Time dtDat
MS Visual InterDev6.0: When compiling web pages related to databases, we often face the problem of data record pagination display due to the huge amount of data to be displayed.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The pagination display when ADO accesses the database is actually to operate the records of the Recordset. So we must first understand the properties and methods of the Reordset object:
BOF attribute: The current indicator refers to the first transaction to the RecordSet.
EOF Attribute: The current indicator refers to the last transaction to the RecordSet.
Move method: Move metrics to a record in the RecordSet.
AbsolutePage property: Set the current record location on which page
AbsolutePosition property: The current position of the metric in the RecordSet.
PageCount property: Displays how many pages of data a Recordset object contains.
PageSize property: Displays the number of records displayed on each page of the Recordset object.
RecordCount property: Displays the total number of records of the Recordset object.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
In Microsoft's ASP programming system, the establishment of ADO objects makes accessing databases from web pages an easy task, especially the ADO Recordset object makes it more convenient and free to display the output of control data. In Visual InterDev6.0 (hereinafter referred to as VI6.0), due to the introduction of object models such as Script Object Model (hereinafter referred to as SOM), Design-Time Control (hereinafter referred to as DTC), and Data Environment Object Model (hereinafter referred to as DEOM), the web page access design becomes more convenient.
Because of the topic, regarding database connections, the following only gives code and brief comments, and focuses on how to use Recordset objects (or controls) to implement pagination display of data records. According to my understanding, the key to pagination display is to master the properties and methods of ADO's Recordset object or DTC (design-time control).
These seven pagination display methods are summarized into four categories:
The first and second types I temporarily call are pure ASP methods, which is also the most commonly used method on domestic ASP websites. Their differences are only in the different implementation techniques. The implementation of these two methods is the easiest to understand, the least object concept is used, and the minimum requirements for the development environment (just as a Notepad). It can be said that the essence of these two methods is still the programming idea of CGI, which is just introducing ADO objects into the program.
The fourth and fifth DHTML methods temporarily named SOM. These two methods require that in the VI6.0 environment, the script object model (Script Object Model) proposed by Microsoft and the new features of the database binding of Table objects in DHTML (many books and articles only introduce the application of the CSS characteristics of DHTML in style design and ignore the introduction of its data binding characteristics) to achieve control page turnover on the client. However, it requires that the user's browser must support DHTML, such as: Microsoft Internet Explorer 4.0 and above.
The sixth method is temporarily named SOM server-side method. It requires development in the VI6.0 environment, which uses several DTC controls in the script object model (Script Object Model) proposed by Microsoft: Recordset, PageObject, Grid, etc. to implement page turn control on the server side (client). This is an exciting and new programming method. It regards web pages as objects (this object model is different from the traditional DOM---document object model: DOM can only control the client, while SOM can control the server and the client), and it truly implements object-oriented programming of web pages. But unfortunately, maybe my personal ability is limited, and I personally think this technology is not very mature yet. For example, the combination with the browser is not very good, which will be explained in detail later.
The seventh method is temporarily named DEOM method. It also uses the Data Environment Object Model established in VI6.0 to create Recordset objects. This is also a relatively rare new method in web programming. Compared with the SOM model, it has its own advantages, which will be described in detail later.
All the source codes mentioned later can be copied and used directly. You may not even understand the principle. Just replace the bold italic part with the corresponding database name or field name.
Before we start introducing various paging methods in detail, let’s create a database: use access in Office97 to create a Employee.mdb, which creates a table emp, and sets only three fields: emp ID, last name and first name. Why is that simple? It is because we care about how to deal with the results of recordset.
The first type: direct substitution method for parameters.
This method is to manually create a Recordset object, and use its pagesize (specify the number of records displayed per page), pagecount (total page number) and absolutepage (current page number) properties to control the output of the page. The page paging uses the method of directly using the page number parameter of <href> to control page turnover. The name of the web page is emp1.asp. The source code is as follows:
<%// Establish a connection to the employee.mdb database.
Set conn = Server.createObject(ADODB.Connection)
conn.Open driver={Microsoft Access Driver (*.mdb)};dbq=employee.mdb
//Create an instance of the Recordset object of the emp table.
Set rs = Server.createObject(ADODB.Recordset)
rs.Open emp, conn, 3
PageSize = 10 //pagesize attribute specifies the number of records to be displayed on each page
Page = CLng(Request(Page)) string type converted to long type
If Page < 1 Then Page = 1
If Page > rs.PageCount Then Page = rs.PageCount
If Page <> 1 Then
Response.Write <A HREF=emp1.asp?Page=1>Page1</A>
Response.Write <A HREF=emp1.asp?Page= & (Page-1) & >Previous Page</A>
End If
If Page <> rs.PageCount Then
Response.Write <A HREF=emp1.asp?Page= & (Page+1) & >Next Page</A>
Response.Write <A HREF=emp1.asp?Page=&rs.PageCount & >Last Page</A>
End If
Response.write page number: & Page & / & rs.PageCount & </font>
//Display of each page
//Show the header
Response.Write <CENTER><TABLE BORDER=1>
Response.WRITE <TR><TD> & rs.Fields(emp ID).Name & </TD>
Share: Operation must use an updateable query" error solution Microsoft OLE DB Provider for ODBC Drivers (0x80004005) appears under XP operating system. The operation must use an updateable query error. Solution 1. When operating the database asp, an updateable query error must use: 2. Folder>Properties; or, Explorer>Tool>Folder options 3. Do not hook in the view tab to select the use simple