Paging data in DataList control
I've built a SQL query that allows me to page data returned from SQL Server (kinda like 10 records per page view or 5 - depends on the setting), which I want to control using query strings. Everything in my query seems to work brilliant as long as its in SQL Management Studio:
SELECT *
FROM (SELECT TOP (10) *
FROM (SELECT TOP (10 * @page) *
FROM [mytable]
WHERE ([dept] = @deptqs)
ORDER BY [emp_id])
WHERE ([id] NOT IN (SELECT TOP (10 * (@page - 1)) [id]
FROM [mytable]
WHERE ([dept] = @deptqs)
ORDER BY [emp_id]))
ORDER BY [emp_id] DESC)
ORDER BY [emp_id]
However, when I try to use this query in the DataList control's data source config, I get these error messages:
Incorrect syntax near the keyword 'WHERE'.
Incorrect syntax near the keyword 'ORDER'.
I dont see any problems with the query. Any idea what I might be doing wrong here? Please suggest.
Cheers!
Zee

