Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9284929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:01:31+00:00 2026-06-18T19:01:31+00:00

I have a query that I put into a dataset as a datatable. The

  • 0

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

enter image description here

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…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T19:01:32+00:00Added an answer on June 18, 2026 at 7:01 pm

    Due to the limitations of the TableAdapter wizard, you have to create the DataTable using code.

    DataTable dataTable;
    
    using (SqlConnection sqlConn = new SqlConnection())
    {
        sqlConn.Open();
    
        using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter())
        using (sqlDataAdapter.SelectCommand = sqlConn.CreateCommand())
        {
    
            sqlDataAdapter.SelectCommand.CommandType = CommandType.Text;
            sqlDataAdapter.SelectCommand.CommandText = '
                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';
    
            sqlDataAdapter.Fill(dataTable);
        }
    }
    

    After having your dataTable filled, simply assign it to the ReportViewer’s DataSource

    ReportDataSource rds = new ReportDataSource(dataTable.TableName, dataTable);
    ReportViewer1.LocalReport.DataSources.Clear();
    ReportViewer1.LocalReport.DataSources.Add(rds);
    

    Please note that a large part of these code snippets are untested.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query that will be put into a procedure, and it will
I have a query that selects data into a custom type- UserData curData =
I have this query that I want to put into the 'modern Join syntax'
I have a long sql query that I am attempting to put into VBA
I have a rather complex DELETE query that I need to break down into
I have a query that I have made into a MYSQL view. This particular
I have the following code that loads an XML file into a datatable (I
I have a dataset from a complex query which I've selected into a temp
I have used a JOIN to put together a query that uses columns from
i have a query that returns ~50k rows, seems like doctrine put this whole

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.