Recommended: parse ASP instance: slide news code The following is the referenced content: !--This is a home page file -->html>head>meta http-equiv=Content-Type content=
1. Create Recordset object
| The following is the quoted content: Dim objMyRst Set objMyRst=Server.CreateObject(ADODB.Recordset) objMyRst.CursorLocation=adUseClientBatch 'The client can be batch-processed objMyRst.CursorType=adOpenStatic 'The cursor type is static |
Note: Recordset object cannot be created using the statement of Set objMyRst=Connection.Excute strSQL, because the Recordset object it has created is adOpenFowardOnly does not support record set pagination.
2. Open the Recordset object
| The following is the quoted content: Dim strSql strSql=select * from ietable objMyRst.Oepn strSql,ActiveConnection,,adCmdText 3. Set the PageSize property of Recordset objMyRst.PageSize=20 The default PageSize is 10 |
3. Set the AbsolutePage property of Recordset
| The following is the quoted content: Dim intCurrentPage intCurrentPage=1 objMyRst.AbsolutePage=intCurrentPage AbsolutePage is 1 to the PageCount value of the Recordset object |
4. Display data
| The following is the quoted content: Response.Write(<table>) PrintFieldName(objMyRst) For i=1 To objMyRst.PageSize PrintFieldValue(objMyRst) objMyRst.MoveNext If objMyRst.Eof Then Exit For Next Response.Write(</table>) |
illustrate:
1. adOpenStatic, adUseCilentBatch, adCmdText are constants defined by adovbs.inc. If you want to use it, copy adovbs.inc to the current directory and include it in the program.
| The following is the quoted content: <! --#Include File=adovbs.inc--> 2. The code of PrintFielName and PrintFieldValue functions is as follows: <% Function PrintFieldName(objMyRst) 'The parameter objMyRst is a Recordset object 'Define the count Dim objFld Response.Write <tr bgcolor='#CCCCCC'> For Each objFld In objMyRst.Fields Response.Write <td> & objFld.Name & </td> Next Response.Write(</tr>) End Function Function PrintFieldValue(objMyRst) 'The parameter objMyRst is a Recordset object 'Define the count Dim objFld Response.Write(<tr >) For Each objFld In objMyRst.Fields 'Response.Write <td> & objMyRst.Fields(intLoop).value & </td> Response.Write <td> & objFld.value & </td> Next Response.Write(<tr>) End Function %> |
Share: Interpret the code of multi-keyword query In web development, I often encounter multiple keyword pairs of single field queries, which I usually implement through dynamic arrays. Of course, multiple keywords are generally separated by spaces or,. I assume that multiple keywords are separated by spaces, the keyword string is keyStr, and the specific code is