Let me know what you think about the following code:
DECLARE @MaxIdValue int
DECLARE @MaxSortFieldVa lue nvarchar(50)
SELECT TOP 1 @MaxIdValue = [id], @MaxSortFieldVa lue = [SortField]
FROM (
SELECT TOP PageNumber*Rows PerPage [id], [SortField]
FROM MyTable
WHERE (FilterConditio n) ORDER BY [SortField], [id]
) T
ORDER BY [SortField] DESC, [id] DESC
SELECT TOP RowsPerPage * FROM MyTable
WHERE ([SortField] >= @MaxSortFieldVa lue) AND (([id] > @MaxIdValue) OR
([SortField] <> @MaxSortFieldVa lue)) AND (FilterConditio n)
ORDER BY [SortField], [id]
This is a dynamic SQL and it should be easily fixable.
PageNumber, RowsPerPage, FilterCondition and SortField are going to be
the variables and will be based on the user's search
condition/criteria.
-----------------------------
Thanks for you attention. 2 2796
"Kurzman" <ma*@virtuman.c om> wrote in message
news:d8******** *************** ***@posting.goo gle.com... Let me know what you think about the following code: DECLARE @MaxIdValue int DECLARE @MaxSortFieldVa lue nvarchar(50)
SELECT TOP 1 @MaxIdValue = [id], @MaxSortFieldVa lue = [SortField] FROM ( SELECT TOP PageNumber*Rows PerPage [id], [SortField] FROM MyTable WHERE (FilterConditio n) ORDER BY [SortField], [id] ) T ORDER BY [SortField] DESC, [id] DESC
SELECT TOP RowsPerPage * FROM MyTable WHERE ([SortField] >= @MaxSortFieldVa lue) AND (([id] > @MaxIdValue) OR ([SortField] <> @MaxSortFieldVa lue)) AND (FilterConditio n) ORDER BY [SortField], [id]
This is a dynamic SQL and it should be easily fixable. PageNumber, RowsPerPage, FilterCondition and SortField are going to be the variables and will be based on the user's search condition/criteria. ----------------------------- Thanks for you attention.
What I think is that your syntax is wrong :-)
If you want a pagination solution, then the usual answer is "do it on the
client side" - this article may be useful: http://www.aspfaq.com/show.asp?id=2120
Simon
> What I think is that your syntax is wrong :-) If you want a pagination solution, then the usual answer is "do it on the client side" - this article may be useful:
http://www.aspfaq.com/show.asp?id=2120
Simon
The client side is't primary. The bottleneck of pagination is a server
side, especially for a big tables. From this point of view following
code will works slowly. Also it will works correct only if ArtistName
+ '~' + Title is unique.
ArtistName + '~' + Title= @aname + '~' + @title
Following code hasn't this problem:
([SortField] >= @MaxSortFieldVa lue) AND (([id] > @MaxIdValue) OR
([SortField] <> @MaxSortFieldVa lue)) AND (FilterConditio n)
ORDER BY [SortField], [id]
If index [SortField], [id] exist it works fast.
P.S. Thanks for a link to intresting article. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sharif T. Karim |
last post by:
Anyone know of a up-to-date tutorial for pagination where I can have it
like:
Prev 1 2 3 4 Next
Thanks.
--
Sharif T. Karim
....you don't know wrath yet...
|
by: Faree |
last post by:
I am workign on a news portal which needs paginaiton as usual.but all
the code i got depends on the number of records that will come from
database :( .it is working well too.
But i need pagination depends on the number of rows or number
characters in a variable.for example if there are more than 100
characters in that it should be display with pagination code.could any
one comeup with suggestios on this .
|
by: Mohit Gupta |
last post by:
Hi all,
Consider the following ASP program.
`````````````
OLD ASP STYLE
`````````````
~~~~~~~~~~
|
by: Chris H |
last post by:
I am having a problem with pagination, basically the problem is happening in
the "PREV / NUMBERS / NEXT" links, it appears as if the reason is becasue
the increment and decrement operators aren't functioning or the $page
variable isnt working in that part of the code... Below is the link to the
working but broken page.. as well as the main part of my code... Hopefully
someone can explain why the operators arent working or maybe see what i...
|
by: ste |
last post by:
Hi there,
Further to my recent posts where I've received excellent help from Rik and
Jerry, I've ended up with an image gallery on my website that displays
images in a table, 3 images per row. This works great and opens all images
in the database when I open the url mywebsite/gallery.php, or I can choose
certain images (by category) by going to url's like
mywebsite/gallery.php?category=landscape
Although the above worked perfectly...
| |
by: shalini jain |
last post by:
Hi, I want to know how can we do pagination using XSL. There are number of tutorials available on pagination using PHP but nothing with XSL. i am really stuck with my code.
Below is the code that i have written for pagination but it displays the link of all the pages at one go i.e. if i have 8 pages showing 10 results per page than it shows links for all 8 pages.
Previous 1-10 11-20 21-30 31-40 41-50 51-60 61-70 71-80 Next
i want to...
|
by: gnawz |
last post by:
I have a pagination function I am using in a file called functions.php as below<? //Pagination functions function getPagingQuery($sql, $itemPerPage = 10) { if (isset($_GET) && (int)$_GET > 0) { $page = (int)$_GET; } else { $page = 1; } // start fetching from this row number $offset = ($page - 1) * $itemPerPage; return $sql . " LIMIT $offset, $itemPerPage"; } /* Get the links to navigate between...
|
by: ArizonaJohn |
last post by:
Hello,
The code below works great. The user enters a name into an HTML form, the code looks up a table with that name, and then that table is displayed.
I am trying to use pagination with it, and the pagination almost works. The first page of the pagination works fine, but when I click on one of the links for one of the next pages, the page is blank.
I have seen people mention this problem, and they have been told that a variable is...
|
by: kkshansid |
last post by:
this is my search page on which i am getting two parameters from previous page but the problem is that as soon as i click any other next pages my sql query fails as it doesnt get these two parameters
kindly help
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |