Link to home
Start Free TrialLog in
Avatar of BenthamLtd
BenthamLtd

asked on

Recordset paging in VB ASP with mySQL Database

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

Avatar of Ashish Patel
Ashish Patel
Flag of India image

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.
ASKER CERTIFIED SOLUTION
Avatar of Dirar Abu Kteish
Dirar Abu Kteish
Flag of Palestine, State of image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Forced accept.

Computer101
EE Admin