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 947187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:02:43+00:00 2026-05-15T23:02:43+00:00

I am new to ADO.net and have this problem: Let’s assume I have these

  • 0

I am new to ADO.net and have this problem:

Let’s assume I have these two tables in a SQL Server 2005 database, with these columns:

[Orders]

  • OrderID
  • OrderDate
  • ShopID
  • TotalAmount
  • TotalTaxAmount
  • etc…

[OrdersDetails]

  • OrderID
  • ShopID
  • ItemID
  • Quantity
  • Amount
  • TaxAmount
  • etc

I have started a WinForms application to get myself started.
In this form, the user can select a list of Shops and select a date range to see all orders from this shop.

I have added a data source from Visual Studio, select both Orders and OrdersDetails table and dragged and dropped the Orders and related OrdersDetails tables into the form as DataGridViews.

When I select a row from the Orders DataGridView, I indeed see the corresponding Orders Details in the second DataGridView as I wanted. I had relationships inside this database and ADO.net caught them up and reflected them in the dataset.

I have then added a method to my typed dataset to get data by the OrderDate, and ShopID column.
As the OrdersDetails table does not have an OrderDate column, I could only filter it by ShopID.

The issue is that it is time consuming to get the records from the OrdersDetails as it will retrieve more rows than needed into the DataTable for the OrdersDetails.
The problem is that I can only filter the rows from the OrderDetails table by ShopID, which returns way too many records from the database.

Obviously, ADO.net is able to filter them appropriately on the client-side by using the OrderID relationship but it would make much more sense to retrieve only the rows from the OrdersDetails that I actually need.

I have modified my queries getting the data from the second table to add the OrderDate using a join, so I can filter by date when I retrieve the data from the database… however, it causes problems when I try to update my changes due to this foreign column…

I believe there must be an easy way around this, isn’t there?

Thanks a lot in advance.

  • 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-05-15T23:02:44+00:00Added an answer on May 15, 2026 at 11:02 pm

    You want to do something like this

    SELECT *
    FROM OrderDetails
    WHERE
        ShopID IN ( @listOfShopIds )
        AND
        OrderID IN (
            SELECT OrderID
            FROM Orders
            WHERE
                OrderDate BETWEEN @dateFrom AND @dateTo
        )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm simply trying to get data from two sql server db tables using ado.net
I am using ado.net to access sql server I have costum Stored Procedure I
I'm new to ADO.NET so asking for help. I have to insert large number
Technical Details C#, ASP.NET 4, MVC 3, SQL backend, ADO.NET (edmx) Background/Context I have
I'm pretty new to MVC 2 using the Entity Framework. I have two tables
Let's say I have a northwind database and I use ADO.NET Entity Data Model
I have a brand new server with Windows 2008 Server 64 bit + SQL
I am developing using VS2012, SQL Server 2008 and ASP NET MVC I have
I create a database using ADO.NET SQL queries like this: create database mydatabase create
I have an ASP.NET MVC Web Application that interacts with a SQL Server 2008

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.