Solved

How split odbc search result in several Pages?

Posted on 1998-08-24
11
198 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
[X]
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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Search Item in Table 2 43
href return to normal window 5 31
Can't get cursor to change 3 16
Popup write two lines 3 22
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

733 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