Solved

How split odbc search result in several Pages?

Posted on 1998-08-24
11
196 Views
Last Modified: 2010-04-09
Based on the client's input I want to give him the result in several pages instead of one large one. The first page (result) shall show up by default. If there are more pages
the user shall be able to push "next n", "prev n" or similar to get the results on the next/prev page and so on..

I hope this can be solved without first generating all the
pages based on the clients search criteria, before sending the first page to the client, to reduce the payload on the server.

I'm familiar with using ASP to retrieve data from an AccessDB using ODBC.
I use FrontPage98, Access, with the ability to use ASP-pages

If you have suggestions to articles about the issue..nice..
If not but you know how to do it and can give me an example..nice2..

0
Comment
Question by:erot
  • 7
  • 3
11 Comments
 
LVL 10

Expert Comment

by:MasseyM
ID: 1836969
Why don't you set session variables for each person and then when they request an item, search until x = number they want.  At that time, record the index Number in the Access DB... Then, whn they click next, go directly to that index and search from there...

1) this assumes that each record has a distinct identificaion number (autonumber works)...
2) not sure how you would implement a previous list unless you save those to disk...

- Matt

If you want, I will try to round some source together.
0
 
LVL 10

Expert Comment

by:MasseyM
ID: 1836970
Please read the abve response....
0
 

Author Comment

by:erot
ID: 1836971
I can see you know how to...but there is no examples or
links to sites with examples...

I would very much like to see the source that you mentioned!!

erot
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 10

Expert Comment

by:MasseyM
ID: 1836972
Give me about a day or two and I will put something together....

0
 

Author Comment

by:erot
ID: 1836973
Thank you...MasseyM i'm looking forward to the result!!!

Erot
0
 

Expert Comment

by:wanted
ID: 1836974
How many data in your database?

0
 
LVL 10

Expert Comment

by:MasseyM
ID: 1836975
Same question as wanted... Also, what kind of information?  I am almost finished with the code... I will email it to you asap... what is your email address?
0
 
LVL 10

Accepted Solution

by:
MasseyM earned 140 total points
ID: 1836976
Here you go.. This is not perfect, but it gets the job done... I would reccomend that you tet it VERY thoroughly before using it... I tested it on a database of 15 records and all ways well..

Here is the Access DB setup:
[Items] - Table
ItemID - AutoNumber / Identification
URL - Text / Link to whatever
Description - Memo / Search Field
KeyWords - Text / Not used, but could be...

Code is posted as a comment.
0
 
LVL 10

Expert Comment

by:MasseyM
ID: 1836977
SEARCH.ASP
--------------------------------------------
<%
Param = Request.QueryString("Param")
Data = Request.QueryString("Data")
%>
<%
If IsObject(Session("SEARCH_conn")) Then
    Set conn = Session("SEARCH_conn")
Else
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.open "SEARCH","",""
    Set Session("SEARCH_conn") = conn
End If
%>
<%
    sql = "SELECT Items.ItemID, Items.URL, Items.Description, Items.KeyWords "
    sql = sql & "FROM [Items] "
    If cstr(Param) <> "" And cstr(Data) <> "" Then
                      '    sql = sql & " WHERE [" & cstr(Param) & "] = " & cstr(Data)
    End If
    sql = sql & "ORDER BY Items.ItemID;"    
    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.Open sql, conn, 3, 3
%>

<% SearchString = Request.Form("SearchString") %>
<% TotalItemsWanted = Request.Form("TotalItemsWanted") %>
<% NumberToSkip = Request.Form("Skip") %>
<% If NumberToSkip = "" then NumberToSkip=0 %>
<TABLE>
<TH>Searching for: <%=SearchString%> </TH><TH>Displaying <%=TotalItemsWanted%> items per session.

<% If NumberToSkip > 0 then %>
<% Skipped = 0 %>
      <%
      On error Resume Next
      rs.MoveFirst
      do while not rs.eof and CInt(Skipped) < CInt(NumberToSkip)
      %>
      <% if Instr(UCase(rs.Fields("Description")), UCase(SearchString)) then %>
      <% Skipped = Skipped + 1 %>
      <% End If %>
      <%
      If Skipped < NumberToSkip then rs.MoveNext
      loop
      %>
<% End If %>
<% TotalItemsInDB = Skipped %>
<% CurrentItemShown = 1 %>

<%
On Error Resume Next
do while Not rs.eof
%>

      <% If InStr(UCase(rs.Fields("Description")), UCase(SearchString)) then %>
            <% TotalItemsInDB = TotalItemsInDb + 1 %>
            <% If cint(CurrentItemShown) <= cint(TotalItemsWanted) then %>
                  <TR>
                  <TD><% =rs.Fields("ItemID") %></TD>
                  <TD><% =rs.Fields("Description") %></TD>
                  <TD><A HREF="<% =rs.Fields("URL") %>">Go There</A></TD>
                  </TR>
            <% End If %>
            <% CurrentItemShown = CurrentItemShown + 1 %>
      <% End If %>
<%
rs.MoveNext
loop%>
</TABLE>
<FORM ACTION="Search.Asp" METHOD=POST>
<% SkipThis =cint(NumberToSkip) + cint(TotalItemsWanted) %>
<INPUT TYPE=HIDDEN NAME="Skip" Value="<% =SkipThis%>">
<% MsgBox(Request.Form("Skip") + TotalItemsWanted ) %>
<INPUT TYPE=TEXT NAME="SearchString" VALUE="<%=Request.Form("SearchString")%>">
Locate <SELECT NAME="TotalItemsWanted">
<OPTION>1</OPTION>
<OPTION>2</OPTION>
<OPTION>3</OPTION>
<OPTION>4</OPTION>
<OPTION SELECTED>5</OPTION>
</SELECT> Matches.
<% If SkipThis< TotalItemsInDB Then %><INPUT TYPE=SUBMIT><% End If %>
</FORM>
Located <I><% =TotalItemsInDB %></I> total Matches.

<% rs.close %>
<% TotalItemsInDB = 0 %>
<% TotalItemsWanted = 0 %>

SEARCHFORM.ASP
----------------------------------
<FORM ACTION="Search.Asp" METHOD=POST>
<INPUT TYPE=HIDDEN NAME="Skip" Value="0">
<INPUT TYPE=TEXT NAME="SearchString" VALUE="">
<INPUT TYPE=SUBMIT>
Locate <SELECT NAME="TotalItemsWanted">
<OPTION>1</OPTION>
<OPTION>2</OPTION>
<OPTION>3</OPTION>
<OPTION>4</OPTION>
<OPTION SELECTED>5</OPTION>
</SELECT> Matches.
</FORM>
<% TotalItemsInDB = 0 %>
<% TotalItemsWanted = 0 %>
0
 

Author Comment

by:erot
ID: 1836978
...have been sleeping....
  here are the fields in the table...
  Country (= Name of country) can be "Countryname" or "All".
  Type    (= Long, Short, Fat, Thin) can be "One of those 4" or
           all.
  CustomSearch (can be every string)

  The customer can choose none, one or a combination.
  (country and type from a dropdownlist. CustomSearch
  by filling out a Text box.

  my E-mail are krudtaa@yahoo.com
0
 
LVL 10

Expert Comment

by:MasseyM
ID: 1836979
If you REALLY want me to, I will customize this to your database... Just email me your database (So I don't have to populate my own) and I will do it...  (ut, just remember, this would normally be $100/hr by any consultant (Taken me about 3 hours thus far).. but I am happy to do so because I am going to use the code as well...
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

831 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