I have a query that I put into a dataset as a datatable. The query runs great, however in the datatable it does not list anything in the Data Column, there for I cannot report it… Any ideas why this is not working? My Query is below.
SELECT * FROM (
SELECT timeclock.dtTimeIn, timeclock.dtTimeOut, employees.sfirstname,
RANK() OVER ( ORDER BY dtTimeIn) rk1, --earliest record gets 1
RANK() OVER (ORDER BY dtTimeOut DESC) rk2 --latest record gets 1
FROM TimeClock INNER JOIN
Employees ON TimeClock.lEmployeeID = Employees.lEmployeeID
WHERE (dtTimeIn > dateadd(day, datediff(day, 0, getdate())-1, 0)) AND (dtTimeOut < dateadd(day, datediff(day, 0, getdate()), 0)) AND
(sDept IN ('1', '2', '3'))
) A
WHERE rk2=1
Current output when I run the query:
dtTimeIn dtTimeOut sfirstname rk1 rk2
2/7/2013 2:36:00 PM 2/7/2013 7:52:33 PM Brian 10 1

When Creating the Table adapter in the wizzard… I get an error message:
The Wizard detected the following problems when configuring the TableAdapter:
"OpenTime":
Details:
Generated SELECT statement.
The OVER SQL construct or statement is not supported
To add these components to your dataset, click Finish.
I’m guessing it doesn’t like the query… But i’m not sure how else to accomplish the query other than using the “OVER” function…
Due to the limitations of the
TableAdapterwizard, you have to create theDataTableusing code.After having your
dataTablefilled, simply assign it to the ReportViewer’sDataSourcePlease note that a large part of these code snippets are untested.