blackcat9000
Programmer
Hi yer bro's.
My problem is i am trying to produce results based on a selection.
Now it brings up the first page of the results ok, but if there are more that one page of results and i proceed to see further pages I seem to lose the recordset connection and it brings me back to my main menu page.
example below:
<%
Dim Con
Dim rsPage
Dim Page
Dim RowCount
Dim PageCounter
Dim u_where
Dim u_search
u_search=request.form("u_search")
u_where=request.form("u_where")
if u_search = "" or u_where= "" then
response.redirect "main.asp"
end if
Page = Request.QueryString("Page")
If Page = "" then Page = 1
RowCount = 0
DSNtemp = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath("Samples.mdb")
set conn = CreateObject("ADODB.Connection")
conn.open DSNtemp
Set rsPage = Server.CreateObject("ADODB.Recordset")
lsSQL = "select * from Sample where " & u_where &" like '%%"& u_search & "%%'"
rsPage.CursorType = 3 'adOpenStatic
rsPage.PageSize = 10
rsPage.Open lsSQL, Conn
TotalRecs = rsPage.recordcount
TotalPages = cInt(rsPage.pagecount)
rsPage.AbsolutePage = cInt(Page)
%>
<%
If Response.IsClientConnected = true then
response.write "<td width = 100% bgcolor = #ffffff><b><center><font face=Verdana size=2>The following results met your search criteria for <font color=#ff0000>'"& u_search & "'</b></center></td>"
response.write "<br><Font face='arial' size=2><font color=#000000>There are " & TotalRecs & " entries in " & TotalPages & " pages</font><br>"
response.write "<br></br>"
Do while not rsPage.eof and RowCount < rsPage.PageSize
ID = rsPage("ID")
Name = rsPage("Name")
%>
<%
rsPage.Movenext
RowCount = RowCount + 1
Loop
For PageCounter = 1 to rsPage.PageCount
Response.Write "<a href='results3.asp?Page=" & PageCounter & "&u_search=" & Server.URLEncode(u_search) & "'>" & PageCounter & "</a> "
Next
rsPage.Close
set rsPage = Nothing
End if
%>
Can any guru help?
Thanks in advance
My problem is i am trying to produce results based on a selection.
Now it brings up the first page of the results ok, but if there are more that one page of results and i proceed to see further pages I seem to lose the recordset connection and it brings me back to my main menu page.
example below:
<%
Dim Con
Dim rsPage
Dim Page
Dim RowCount
Dim PageCounter
Dim u_where
Dim u_search
u_search=request.form("u_search")
u_where=request.form("u_where")
if u_search = "" or u_where= "" then
response.redirect "main.asp"
end if
Page = Request.QueryString("Page")
If Page = "" then Page = 1
RowCount = 0
DSNtemp = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath("Samples.mdb")
set conn = CreateObject("ADODB.Connection")
conn.open DSNtemp
Set rsPage = Server.CreateObject("ADODB.Recordset")
lsSQL = "select * from Sample where " & u_where &" like '%%"& u_search & "%%'"
rsPage.CursorType = 3 'adOpenStatic
rsPage.PageSize = 10
rsPage.Open lsSQL, Conn
TotalRecs = rsPage.recordcount
TotalPages = cInt(rsPage.pagecount)
rsPage.AbsolutePage = cInt(Page)
%>
<%
If Response.IsClientConnected = true then
response.write "<td width = 100% bgcolor = #ffffff><b><center><font face=Verdana size=2>The following results met your search criteria for <font color=#ff0000>'"& u_search & "'</b></center></td>"
response.write "<br><Font face='arial' size=2><font color=#000000>There are " & TotalRecs & " entries in " & TotalPages & " pages</font><br>"
response.write "<br></br>"
Do while not rsPage.eof and RowCount < rsPage.PageSize
ID = rsPage("ID")
Name = rsPage("Name")
%>
<%
rsPage.Movenext
RowCount = RowCount + 1
Loop
For PageCounter = 1 to rsPage.PageCount
Response.Write "<a href='results3.asp?Page=" & PageCounter & "&u_search=" & Server.URLEncode(u_search) & "'>" & PageCounter & "</a> "
Next
rsPage.Close
set rsPage = Nothing
End if
%>
Can any guru help?
Thanks in advance