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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:49:55+00:00 2026-05-27T21:49:55+00:00

I have few tables in the database with parent table say P is having

  • 0

I have few tables in the database with parent table say P is having 1:1 relation with some child tables whereas having 1:M relation with other child tables.

For this I have added DataSet at design time by ‘Add -> New Item -> DataSet -> DataSet1.xsd’
So, I have all the required tables along with their 1:1 or 1:M relations.

I have applied some filter on main table adapter so that only selected records from parent table and their related child records are populated in the dataset. And finally, I want to write this data from DataSet to Xml file.

But, I am getting one issue – the final dataset that I am getting is having all the records from child table. Instead it should have only those child records for which parent table is having related records.

I am using following code –

ParentDataSet parentDataSet = new ParentDataSet();
 ParentTableAdapter parentTableAdapter = new ParentTableAdapter();
 parentTableAdapter.Fill(parentDataSet.ParentTable, column1Value); // All fine until here as I have applied filter in tableAdapter SQL

 ChildTableAdapter childTableAdapter = new ChildTableAdapter();
 //returns all rows in the child table -- shouldn't it return only those child records for which parent dataset table is having records??
 childTableAdapter.Fill(parentDataSet.ChildTable);  

 parentDataSet.WriteXml(xmlFilePath);

Please guide what I am missing here?

Thank you!

  • 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-27T21:49:56+00:00Added an answer on May 27, 2026 at 9:49 pm

    Have you seen this article? The author says that

    By default, the DataSet designer sets the DataRelations between
    parent-child tables as “Relation Only”. This means that the DataSet
    will not enforce the foreign key constraints on the client, just your
    database…

    Try changing the type of the parent-child relation to a foreign key constraint. Then, check the SelectCommand property of the ChildTableAdapter. It is filtering the data the way you expect.

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

Sidebar

Related Questions

So I have a database with a few tables. The first table contains the
Say I have a few tables in the MSSQL database, each with about 5-10
I have a few tables in a MySQL database similar to this setup: major
I have some tables in my postgres database, and a few of them inherit
I have a simple database with few tables (and some sample columns): Posts (ID,
I have a MS Access database with few tables and a form. When more
I have several database tables that just contain a single column and very few
In my database, I have a few columns in one of my tables that
I have a few classes, such as those that outline database table structure or
I have quite a few situations where I have database structures similar to: TABLE

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.