473,396 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How next button in search works - Design problem

Hi,

May be I am a newbie, or may be i dont have that much insight in following
systems ..i.e. why i have some confusions as below:

In many websites, when search is performed on some keywords (not only
including google which perform general search but other sites which perform
seach on a particular type of item in their database) then many search
results are obtained (for example more than 100 or even more than 1000) but
only limited amount of results are displayed in a page (like for example 10
results per page). Thus in order to display the next 10 results, a user has
to click on 'Next' button. Similarly, it is possible that a user can click
on 'Previous' button to display the previous 10 results. My question is what
are different mechanisms to perform this and which one would be most optimal
than others?

Why I am asking this question because, if we are performing a search by
sending a query of keywords to a website then we get following procedure:

Browser->Send Query->ASP.NET page(considering we are using ASP.NET although
it could be PHP or ASP or JSP etc)

Now internally from ASP.NET page, a database connection is opened (say using
ADO.NET) and search is performed by sending a query to database and getting
the results. So we get:

ASP.NET page->Send query to database (using ADO.NET)

Now database returns recordset containing more than lets say 100 records (or
1000 records)

Database->Send back 1000 records->ASP.NET page

And then ASP.NET page send 10 records to client and drop the rest. So:

ASP.NET page->Send 10 records->Client Browser.

So now when the client press Next button what happens? It seems illogical to
send same search query to database and then dropping first 10 records from
recordset and only passing recordset from 11th record to 20th records to
client browser.

So, can anyone please tell me what are different approaches to handle this.

Thanks,

Arsalan
Mar 28 '06 #1
2 2602
Hi,

Have you used paging in the past? Here is how you would do a paging query in
T-SQL:

//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
SELECT TOP <pageSize> *
FROM
(
SELECT TOP (<pageSize> * <pageIndex>)
< columns names>
FROM
< table name >
WHERE
< condition >
ORDER BY < PK column name > DESC
)
AS anyNameYouWant ORDER BY < PK column name > ASC
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
<pageSize> = the number of records to be retrieved
<pageIndex> = the desired page index (1 based)
<column names> = list of the column names
<table name> = source table name and optional joined tables
<condition> = optional filter condition
< PK column name > = the primary key column name (it has to be also present
into the <column names> list)

Sample T-SQL for getting 5 records from the Northwind Employee table from
the second page:

//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
USE Northwind
SELECT TOP 5 *
FROM(
SELECT TOP 10
EmployeeID,
LastName,
FirstName,
Title,
BirthDate,
HireDate
FROM
Employees

ORDER BY EmployeeID DESC

)
AS Employees ORDER BY EmployeeID ASC
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~

USE Northwind

-- Page 1
SELECT TOP 3 *
FROM(
SELECT TOP 3
EmployeeID,
LastName,
FirstName,
Title,
BirthDate,
HireDate
FROM
Employees

ORDER BY EmployeeID DESC

)
AS Employees ORDER BY EmployeeID ASC

-- Page 2
SELECT TOP 3 *
FROM(
SELECT TOP 6
EmployeeID,
LastName,
FirstName,
Title,
BirthDate,
HireDate
FROM
Employees

ORDER BY EmployeeID DESC

)
AS Employees ORDER BY EmployeeID ASC

-- Page 3
SELECT TOP 3 *
FROM(
SELECT TOP 9
EmployeeID,
LastName,
FirstName,
Title,
BirthDate,
HireDate
FROM
Employees

ORDER BY EmployeeID DESC

)
AS Employees ORDER BY EmployeeID ASC

If using AJAX you could simply return the results you need depending on page
clicked using Callbacks... You'd be amazed at the speed of execution...
Hope this helps,

Yama Kamyar






"Arsalan Ahmad" <ar*****@hotmail.com> wrote in message
news:OT**************@TK2MSFTNGP11.phx.gbl...
Hi,

May be I am a newbie, or may be i dont have that much insight in following
systems ..i.e. why i have some confusions as below:

In many websites, when search is performed on some keywords (not only
including google which perform general search but other sites which
perform seach on a particular type of item in their database) then many
search results are obtained (for example more than 100 or even more than
1000) but only limited amount of results are displayed in a page (like for
example 10 results per page). Thus in order to display the next 10
results, a user has to click on 'Next' button. Similarly, it is possible
that a user can click on 'Previous' button to display the previous 10
results. My question is what are different mechanisms to perform this and
which one would be most optimal than others?

Why I am asking this question because, if we are performing a search by
sending a query of keywords to a website then we get following procedure:

Browser->Send Query->ASP.NET page(considering we are using ASP.NET
although it could be PHP or ASP or JSP etc)

Now internally from ASP.NET page, a database connection is opened (say
using ADO.NET) and search is performed by sending a query to database and
getting the results. So we get:

ASP.NET page->Send query to database (using ADO.NET)

Now database returns recordset containing more than lets say 100 records
(or 1000 records)

Database->Send back 1000 records->ASP.NET page

And then ASP.NET page send 10 records to client and drop the rest. So:

ASP.NET page->Send 10 records->Client Browser.

So now when the client press Next button what happens? It seems illogical
to send same search query to database and then dropping first 10 records
from recordset and only passing recordset from 11th record to 20th records
to client browser.

So, can anyone please tell me what are different approaches to handle
this.

Thanks,

Arsalan

Mar 29 '06 #2
Arsalan,

In ASPNET are for that nice solutions named Paging (as the name is for a
windforms as well).
Here a sample on our page for a webpage (there are as well for windowforms)

http://www.vb-tips.com/default.aspx?...8-6750bb0390f8

For the others search on 'Paging"

I hope this helps,

Cor

"Arsalan Ahmad" <ar*****@hotmail.com> schreef in bericht
news:OT**************@TK2MSFTNGP11.phx.gbl...
Hi,

May be I am a newbie, or may be i dont have that much insight in following
systems ..i.e. why i have some confusions as below:

In many websites, when search is performed on some keywords (not only
including google which perform general search but other sites which
perform seach on a particular type of item in their database) then many
search results are obtained (for example more than 100 or even more than
1000) but only limited amount of results are displayed in a page (like for
example 10 results per page). Thus in order to display the next 10
results, a user has to click on 'Next' button. Similarly, it is possible
that a user can click on 'Previous' button to display the previous 10
results. My question is what are different mechanisms to perform this and
which one would be most optimal than others?

Why I am asking this question because, if we are performing a search by
sending a query of keywords to a website then we get following procedure:

Browser->Send Query->ASP.NET page(considering we are using ASP.NET
although it could be PHP or ASP or JSP etc)

Now internally from ASP.NET page, a database connection is opened (say
using ADO.NET) and search is performed by sending a query to database and
getting the results. So we get:

ASP.NET page->Send query to database (using ADO.NET)

Now database returns recordset containing more than lets say 100 records
(or 1000 records)

Database->Send back 1000 records->ASP.NET page

And then ASP.NET page send 10 records to client and drop the rest. So:

ASP.NET page->Send 10 records->Client Browser.

So now when the client press Next button what happens? It seems illogical
to send same search query to database and then dropping first 10 records
from recordset and only passing recordset from 11th record to 20th records
to client browser.

So, can anyone please tell me what are different approaches to handle
this.

Thanks,

Arsalan

Mar 29 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Dave Smithz | last post by:
Hi, In summary: I want to a form to submit information via a HTTP POST, however, when using Internet Explorer I want to be able to use the back button and all the information retained....
3
by: Marcel | last post by:
Hello, I'm working on a search application for my website. The website contains a lot of pictures, and a search should return clickable thumbnails. No problems there. My problem started when I...
2
by: Marlene A. Roman | last post by:
Hello I have a question: I have a datagrid. I can make a specific search using some parameters I write and When a press a command button it calls an sp and returns the results of a search that...
3
by: Penny Bond | last post by:
Hi, Any help or suggestions on this one would be gratefully appreciated: I have 2 aspx pages one is called 'Query' and the other 'Details'. Query page has a number of text boxes and drop...
19
by: darrel | last post by:
On my vb.net page, I have 4 sets of inputs + form buttons. example: Search: (GO) Zip: (GO) County: (GO) County: (GO) The problem is if I go to the page, type in a zip code, and hit...
3
by: Arsalan Ahmad | last post by:
Hi, May be I am a newbie, or may be i dont have that much insight in following systems ..i.e. why i have some confusions as below: In many websites, when search is performed on some keywords...
7
by: Bjorn Sagbakken | last post by:
Hello. There maybe an simple answer to this, but sometimes one get a strange blindness when working intensely on one single problem. I'm using ASP.NET 2003, building pages that include 3 user...
3
by: bluez | last post by:
I want to design a webpage where user can search the data from the database and list out the related records. Each of the record got a delete button which allow user to delete the record. ...
4
by: QntmPg | last post by:
Hi all I am trying to design a database that holds contact/demographic information on a person and what studies they have participated in. I have a few ideas, but wanted to get feedback on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.