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

  • Home
  • SEARCH
  • 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 3752262
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:12:58+00:00 2026-05-19T09:12:58+00:00

I am trying to use DataSet and DataAdapter to filter and navigate DataRows in

  • 0

I am trying to use DataSet and DataAdapter to “filter” and “navigate” DataRows in DataTables.

THE SITUATION:
I have multiple logical objects, e.g. Car, Door and Hinge.
I am loading a Form which will display complete Car information including each Door and their respective Hinges. In this senario, The form should display info for 1 car, 4 doors and 2 hinges for each door.

Is it possible to use a SINGLE DataSet to navigate this Data? i.e. 1 DataRow in car_table, 4 DataRow in door_table and 8 DataRow in hinge_table, and still be able to navigate correctly between the different object and their relations? AND, able to DataAdapter.Update() easily?

I have read about DataRelation but don’t really understand how to use it. Not sure if it is the correct direction for my problem.

  • 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-19T09:12:59+00:00Added an answer on May 19, 2026 at 9:12 am

    If you’re looking for an answer towards using DataSets, this won’t be it. Instead, I would like to offer an alternative suggestion: If possible, don’t use DataSets.

    (This is of course a matter of preference, but here’s the reason for my suggestion: DataSets, especially when they’re of the untyped sort, have the disadvantage of being very generic — they have no inherent knowledge of what kind of objects are stored inside them. Contrast this with your “logical objects” who have a notion what they are, and what capabilities they might have. Later, when you’ll need to maintain your code, such objects will be far easier to understand than an opaque DataSet! Add to this the fact that you seem to already have identified your domain objects and seem to have difficulties with the DataSet in the first place.)

    Instead of using a DataSet for your scenario, I would write some data provider classes for these logical objects (Car, Door, and Hinge each get their corresponding data provider class: ICarProvider, IDoorProvider, IHingeProvider) and gather the required data from them when you load your form with data.

    var carId = ...;
    Car car = carProvider.GetCarById(carId);
    

    You would then delegate loading of the door data to the Car class (since the doors “belong” to the car). Make that class have a collection property, Doors (e.g. of type ICollection<Door>). Inside your Car class, you might load door data as follows:

    public ICollection<Door> Doors { get; private set; }
    
    private readonly IDoorProvider doorProvider = ...;
    
    ...
    this.Doors = doorProvider.GetDoorsOfCar(this);
    

    Likewise, delegate loading of the hinges data to the Door class, since the hinges seem to logically “belong” to a door. The Door class would then have a Hinges property (again, e.g. of type ICollection<Hinge>). Again, your Door class might load hinge data as follows:

    public ICollection<Hinge> Hinges { get; private set; }
    
    private readonly IHingeProvider hingeProvider = ...;
    
    ...
    this.Hinges = hingeProvider.GetHingesOfDoor(this);
    

    When you then load your form, you simply set your controls’ values to the corresponding properties of your car object.


    P.S.: My answer makes quite a few assumptions about your object model and the relationships between your objects. Feel free to adapt my answer to the object model you’ve actually got.

    P.P.S.: You could even go a step further. For your form, define various user controls that represent one door, or one hinge. They can get their data directly from a Door or Hinge class. Then, create a user control that can initialise itself from an ICollection<Door> (or an ICollection<Hinge>, respectively), and that creates the right number of Door/Hinge child controls inside itself. That way, you should be able to use data binding to load your form data directly from a Car object.


    Reply to the first two comments by Jake:

    No, I meant something different. What I said was that you can do better than using DataSets. I would personally strive for a solution that does not use DataSets at all. I had something in mind like this:

    interface ICarProvider
    {
        Car GetCarById(int id);
        ICollection<Car> GetAllCars();
    }
    
    public CarProvider : ICarProvider { ... }
    // ^ implementation that loads Car objects, e.g. from a relational database
    
    public class Car
    {
        public int Id { get; private set; }
        public ICollection<Door> Doors { get; private set; }
    
        public Car(int id, IDoorProvider doorProvider)
        {
            this.Id = id;
            this.Doors = doorProvider.GetDoorsOfCar(this);
        }
        ...
    }
    
    public interface IDoorProvider
    {
        ICollection<Door> GetDoorsOfCar(Car car);
        ...
    }
    
    public class DoorProvider : IDoorProvider { ... }
    // ^ similar to CarProvider, but loads data for Doors instead.
    
    public class Door
    {
        public int Id { get; private set; }
        public ICollection<Hinge> Hinges { get; private set; }
    
        public Door(int id, IHingeProvider hingeProvider)
        {
            this.Id = id;
            this.Hinges = hingeProvider.GetHingesOfDoor(this);
        }
        ...
    }
    
    ...
    

    You would then data-bind your form controls against these objects directly (via someControlDisplayingCarData.DataSource = someCar;), not against DataSets.

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

Sidebar

Related Questions

While trying to use LINQ to SQL I encountered several problems. I have table
Trying to use an excpetion class which could provide location reference for XML parsing,
Trying to use a guid as a resource id in a rest url but
I' trying to use a Linq query to find and set the selected value
I trying to use ImageInfo and Jython to get information from a image on
I'm trying to use svnmerge.py to merge some files. Under the hood it uses
I've been trying to use SQLite with the PDO wrapper in PHP with mixed
I'm trying to use SQLBindParameter to prepare my driver for input via SQLPutData .
I'm trying to use jQuery to format code blocks, specifically to add a <pre>
I'm trying to use the Optiflag package in my Ruby code and whenever I

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.