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...
You could create a view from your query and then simply select from your view, this should hide the OVER SQL from the tableAdapter.
Due to the limitations of the
TableAdapter
wizard, you have to create theDataTable
using code.After having your
dataTable
filled, simply assign it to the ReportViewer'sDataSource
Please note that a large part of these code snippets are untested.
I think instead of using the drag-and-drop interface to create a tableAdapter, because your query contains the
OVER SQL
construct (like the error says,) you'll have to create your tableAdapter and fill your datatable in code.