Here's how I do it within a T-SQL stored procedure:

 

1.      Select a dataset into a temp table.
2.      Select the page you want from the temp table passing in @PageSize
and @PageNo variables.

 

DECLARE @ExecStr VARCHAR(512)

SELECT @ExecStr = ' * 

        FROM 

           #tmpTable 

        WHERE 

           Id IN ( SELECT TOP ' + CONVERT(VARCHAR(15), @PageSize) + ' Id
FROM #tmpTable WHERE Id NOT IN ( 

              SELECT TOP ' + CONVERT(VARCHAR(15), (@PageSize * @PageNo)) + '
Id FROM #tmpTable ORDER BY #tmpTable .' + @TempSortFieldAndDirection + ' )
ORDER BY #tmpTable .' + @TempSortFieldAndDirection + ' ) 

        ORDER BY #tmpTable.' + @TempSortFieldAndDirection 

            PRINT ' @ExecStr = ' + @ExecStr

            EXEC ('SELECT ' + @ExecStr)

 

The @TempSortFieldAndDirection let's me change the sort field/direction
because it contains a string like "NAME ASC" or "DATE DESC" the name is one
of the fields in the database.

 

If you're a stickler for loose coupling, you'll hide the column names within
the web-services' DAO layer.

 

  _____  

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Ken Bromberger
Sent: Tuesday, May 01, 2007 2:10 PM
To: [email protected]
Subject: [flexcoders] Paging recordsets from a webservice

 

Hi All,

 

                I'm looking for some examples of record set paging. I am
using a .net backend and some of my results of course have more data then I
would like to send to Flex at once.. Are there any resources that would show
me the best way to page my records??? 

 

Thanks for your help! - Ken

 

Reply via email to