Partitioned Records fetching by Dataset or Datatable

Posted by Ssramvinay under ASP.NET on 8/16/2010 | Points: 10 | Views : 1709 | Status : [Member] | Replies : 1
Hi ALL,

I have 1Lakh records in a table called 'Employee'.Now i am going to display those records in a Gridview with the help of datatable or dataset.(this is the query:select empid,empname,empage from employee).I have enabled Paging and my page size is to display only 1000 in 1st page and another 1000 page in 2nd page....etc option.

I am using Sql server DB.

My problem is :


* All the my 1lakh records are fetched in the Datatable or Dataset once my page loads.So,performance speed gone in very very bad.

My requierment is :

* I am displaying only 1000 records in the 1st page index .So i would like to fetch only these 1000 records in my Datatable or dataset.
Once i went to next page,then only those 1000 records will be populated in the Datatable.

How can we acheive this?Please its very very urgent

NOTE:There is no Where Condition in my Sql Query.

Please give me some suggestions




Responses

Posted by: Shankul2784 on: 8/17/2010 [Member] Bronze | Points: 25

Up
0
Down
Hi,

Please check the below query -

SELECT Description, Date
FROM (SELECT TOP 20 ROW_NUMBER() OVER (ORDER BY Date DESC)
AS Row, Description, Date FROM LOG)
AS LogWithRowNumbers
WHERE Row >= 11 AND Row <= 20

in stored procedure you can pass the top number(like 20), starting point(like 11) & end point (like 20) as parameter from your code.

or you can visit this link for more info -

http://www.davidhayden.com/blog/dave/archive/2005/12/30/2652.aspx


I hope, this will help you.

Thanks & Regards,

Shailesh

Ssramvinay, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response