Hi,
I am working on paging a recordset by using MSQL database.
for some reason it wont display the selected records. It will only
display the records from the first page.
for example:
Page 1 2 3 4 previous next
It will display the data on page 1 but if I click on 2 on page 2 it will say no records found.
if I say: SQL = "SELECT * FROM mid"
then I am able to go from page 1 to page 4 but
if I say: SQL = "SELECT * FROM mid where seeking = '"&request("seeking")&"'"
then I can see the record displayed on page 1 but on page 2 thru 4 it would
say Sorry, There is no result.
I don't know what to do please help.
thanks:
here's my code.
<%@ LANGUAGE = "VBScript" %>
<%
Option Explicit
Dim seeking
seeking = request.form("seeking")
Dim strCon, oCon, pages, Rec, DisplayNum, i, page, SQL, ipage, z
strCon = "DRIVER={MySQL ODBC 3.51 Driver};SERVER= ;DATABASE= ;UID= ;PWD= ;OPTION=3"
Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Const adUseClient = 3
Const adCmdText = 1
page = request.querystring("page")
If page = "" Then
page = 1
else
page = cint(page)
End If
DisplayNum = 0
Set oCon = Server.CreateObject ("ADODB.Connection")
Set Rec = Server.CreateObject ("ADODB.Recordset")
oCon.Open strCon
Rec.PageSize = 2
Rec.CursorLocation = adUseClient
' SQL="SELECT * FROM mid"
SQL = "SELECT * FROM mid where seeking = '"&request("seeking")&"'"
Rec.Open SQL, oCon
if Rec.EOF OR Rec.BOF Then
response.write "<br><br>"
response.write "<p align=center><b>Sorry, There is no result ... </b></p>"
else
ipage = Rec.PageCount
if page = 0 or page > ipage Then
Rec.AbsolutePage = ipage
else
Rec.AbsolutePage = page
end if
Do While Not Rec.EOF AND DisplayNum < Rec.PageSize
response.write "<font style=""font-size=12px; font-family : verdana"">" & Rec("relationship") &" "
response.write Rec("seeking") & "</font><br>"
DisplayNum = DisplayNum + 1
Rec.MoveNext
Loop
end if
If ipage > 1 Then
response.write "<p align=center>"
pages = "<b>Pages : "
For z = 1 to ipage
If z = page then
pages = pages & page & " "
Else
pages = pages & " <a href=?page=" & z & ">" & z & "</a>" & " "
End If
Next
response.write pages & " "
End If
if ipage > 1 And page > 1 Then
response.write "<a href=?page="& page - 1 &">Previous</a>"
end if
response.write " "
If ipage > 1 And page < ipage Then
response.write "<a href=?page="& page + 1 &">Next Page</a>"
end if
response.write "</b></p>"
Rec.Close
oCon.Close
set Rec = nothing
set oCon = nothing
%>
Thanks,
lulu
