Paging display of Oracle data record using ASP

zhaozj2021-02-16  39

Paging display of Oracle data record using ASP

I. Introduction

Paters are required when accessing data volumes through the browser. The ASP records the database record paging display can be implemented by the ADO object set Recordset object. Recordset has the following properties for paging display:

PageSize: The number of records shown per page.

PageCount: The system automatically calculates the total number of pages based on the total number of records in the Pagesize and tables set. RecordCount: The total number of records in the table.

AbsolutePage: Represents the current page number. If you set the AbsolutePage property to 3, then the current record moves to Article 1 (That is, Article 31).

After knowing that Recordset has these properties, I believe that everyone feels that the paging display of records is very simple. Turn on the database and table first, set PageSize and AbsolutePage, and finally the recorded data is output to the browser, you can do it. It is true that it is as simple as using Access or SQL Server as a database, because both databases support these few properties for paging of RecordSet. Compared to Access or SQL Server, the Oracle database provides better security, and performance is dominated in the case of large data volume, however Oracle does not support these paging properties. This article will introduce a method of implementing a paging paging to Oracle data using the ASP to enable Oracle users to easily implement recording paging display.

Second, realize process analysis

1, establish a data source

Install Oracle client software, establish DSN through the Microsoft Odbc for Oracle driver, such as "DSN = ServerName; UID = USER; PWD = Password".

2, establish a data sheet

Simple personal data sheet structure is as follows (Name DATA):

Data: Name, Varchar2; Televhone, Number; Email, Varchar2;

3, program code analysis (only in this analysis record display program display.asp)

Personal Data Sheet </ Title></p> <p></ hEAD></p> <p><%</p> <p>SQL = "SELECT * from a" // SQL statement, remove all data from the DATA table</p> <p>// The following to establish a database connection</p> <p>Set conn = server.createObject ("adoDb.connection")</p> <p>CNN.Open "DSN = ServerName; UID = User; PWD = password;"</p> <p>SET RS = Server.createObject ("AdoDb.Recordset")</p> <p>Rs.cursortype = 3</p> <p>Rs.lockType = 3</p> <p>RS.Open SQL, CONN</p> <p>// If there is no record, you will exit it.</p> <p>IF r.eof then</p> <p>Response.end</p> <p>END IF</p> <p>%></p> <p>// The following display head</p> <p><p align = "center"> Personal data <br> </ p></p> <p><div align = "center"></p> <p><center></p> <p><table border = "1" width = "560" cellspacing = "0" cellpadding = "0"> <TR></p> <p><td width = "140" align = "center"> number </ td></p> <p><td width = "140" align = "center"> Name </ td></p> <p><td width = "140" align = "center"> phone </ td></p> <p><td width = "140" align = "center"> e-mail </ td></p> <p></ TR></p> <p><%</p> <p>Recordsperpage = 10 // Sets per page display record number 10 records</p> <p>CurrentPagenumber = 0 // Set the current page number 0</p> <p>INDEX = 1 // Setup number 1</p> <p>// If the current page number parameter is not empty, turn its type to a long integer, and call this parameter.</p> <p>If Request.QueryString ("CurrentPagenumber") <> "" "</p> <p>CurrentPagenumber = CLNG (Request ("CurrentPagenumber")))</p> <p>END IF</p> <p>// Because the default page number starts from 0, the parameters should be reduced by 1</p> <p>CurrentPagenumber = CURRENTPAGENUMBER-1</p> <p>// The following calculation total record number</p> <p>TotalRrecord = 0</p> <p>While (Not Rs.eof)</p> <p>Rs.movenext</p> <p>TotalRecord = TotalRecord 1</p> <p>Wend</p> <p>// The following calculation total page TOTALPAGENUMBER</p> <p>IF (TotalRecord Mod Recordsperpage) = 0 THEN</p> <p>TotalPagenumber = (TotalRecord / RecordsperPage)</p> <p>Else</p> <p>TotalPagenumber = (TotalRecord / RecordsperPage) 1)</p> <p>END IF</p> <p>// If the input page number parameter is less than 0, display the homepage</p> <p>IF currentpagenumber <0 THEN</p> <p>CurrentPagenumber = 0</p> <p>END IF</p> <p>// If the input page number parameter is larger than the total number of pages, the last page is displayed.</p> <p>If CurrentPagenumber> (TotalPagenumber-1) THEN</p> <p>CurrentPagenumber = (TotalPagenumber-1)</p> <p>END IF</p> <p>// Record the pointer to the first record</p> <p>Rs.movefirst</p> <p>// The following allows the record pointer to the previous record before entering the page, walk to the first record of the current page</p> <p>Passnumber = currentpagenumber * Recordsperpage</p> <p>For i = 0 to passnumber -1</p> <p>Rs.movenext</p> <p>NEXT</p> <p>Index = Passnumber 1</p> <p>Number = 1 // Number is the counter</p> <p>/ / The following shows the table content of the current page</p> <p>While (NOT RS.EOF) and (Number <= RecordsperPage)</p> <p>%></p> <p><tr></p> <p><td width = "140" align = "center"> <% "</ td> // number <TD width =" 140 "align =" center "> <% response.write RS "Name")%> </ td> // Name</p> <p><td width = "140" align = "center"> <% response.write rs ("telephone")%> </ td> //</p> <p><td width = "140" align = "center"> <% response.write RS ("email")%> </ td> // email</p> <p></ TR></p> <p><%</p> <p>Rs.movenext</p> <p>INDEX = INDEX 1 // Number plus 1</p> <p>Number = Number 1 // counter plus 1</p> <p>Wend</p> <p>Rs.close</p> <p>%></p> <p></ TABLE></p> <p></ center></p> <p></ div></p> <p></ html></p> <p>// The following form implements the page number navigation</p> <p><Form action = display.asp method = get></p> <p><%</p> <p>If currentpagenumber <> 0 THEN/ If the current page is not the first page, you will provide links to "First" and "Previous"</p> <p>%></p> <p><a href=display.asp?currentpagenumber=15 first page </A></p> <p><a href=display.asp?currentpagenumber=<%=(currentPagenumber) :>> Previous </A></p> <p><%</p> <p>END IF</p> <p>If currentpagenumber <> (TotalPagenumber -1) then // If the current page is not the last page, provide the "next page" and "Last Page" link</p> <p>%></p> <p><a href=display.asp?currentpagenumber=<%=(CurrentPagenumber 2) :>> Next page </A></p> <p><a href=display.asp?currentpagenumber=<%=( TOTALPAGENUMBER) 3> The last page </A></p> <p><%</p> <p>END IF</p> <p>%></p> <p>/ / Realize the record display of a specific page</p> <p>Enter page: <input type = text name = currentpagenumber> Now in the <% = (CurrentPagenumber 1)%> page / total = TotalPagenumber%> page</p> <p>/ / No send button is provided, I will go directly to the car.</p> <p></ Form></p> <p>Third, conclude</p> <p>The above programs are Windows2000 and IIS5.0 in the server side, and the client is running off the Windows 98, and the database uses Oracle8.0.</p> <p>references:</p> <p>[1] "24-hour learning ASP", [United States] Christoph Wille Christian Koller, Xiaoxiang Studio Translated, People's Posts and Telecommunications Publishing House, 2000. [2] "Active Server Page & Web Database", Wang Guo Rong, People's Posts and Telecommunications Publishing House, 2000.</p> <p>Reference website:</p> <p>[1] www.activeedu.net</p> <p>[2] www.vbtip.com</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-27103.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="27103" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.043</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'cYwrmMj1I862DKuYSghnnqAgU1mgwtQq6ZzckRIDVlPaIIEhArO17RL7y_2BhBSqrOrhnbqGZKr2IFFAcJ'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>