Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Recordset paging in VB ASP with mySQL Database

Posted on 2007-11-22
4
1,142 Views
Last Modified: 2008-03-15
Hi,

I'm building a website that needs to connect to a mySQL database.

Using the code below, I can connect to the database and display x amount of records using the LIMIT function of mySQL.

I now want to be able to page through all the records in blocks of x with the pages listed at the bottom and a total count of records.

How can I do this?
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Set OBJdbConn = Server.CreateObject("ADODB.Connection")
OBJdbConn.Open = "Driver={MySQL ODBC 3.51 Driver};Server=admin-sw;Database=ijtd_export; User=root;Password=cre2unat;Option=3;"
%>
 
 
<%
Dim rsCallBackStatus
Dim rsCallBackStatus_numRows
 
SQLQuery = "SELECT * FROM vallinone LIMIT 0, 20"
 
Set rsCallBackStatus = OBJdbConn.Execute(SQLQuery)
 
rsCallBackStatus_numRows = 0
%>
 
 
<%do until rsCallBackStatus.eof%>
 
<%=rsCallBackStatus("Customer_URN")%><br>
 
<%rsCallBackStatus.movenext
		loop%>
 
 
  <%
rsCallBackStatus.Close()
Set rsCallBackStatus = Nothing
OBJdbConn.Close
Set OBJdbConn = Nothing
%>

Open in new window

0
Comment
Question by:BenthamLtd
4 Comments
 
LVL 23

Expert Comment

by:Ashish Patel
ID: 20334028
Hint for getting this done . Start having two variables like currentpage = 1 and noofrows = 20 and apply the variables to your limit like below.
SQLQuery = "SELECT * FROM vallinone LIMIT " & (currentpage * noofrows)-20 & " , " & noofrows
and then keep a hyperlink below the page with currentpage + 1 in ">" sign and move on.

You will have to put some if else logics for "<" or "<<" and ">" or ">>" and that should be good.
0
 
LVL 6

Accepted Solution

by:
dxz2 earned 500 total points
ID: 20357100
0
 
LVL 1

Expert Comment

by:Computer101
ID: 21135886
Forced accept.

Computer101
EE Admin
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Foreword This is an old article.  Instead of using the MySQL extension that was used in the original code examples, please choose one of the currently supported database extensions instead.  More information is available here: MySQLi / PDO (http://…
Creating and Managing Databases with phpMyAdmin in cPanel.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question