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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:17:59+00:00 2026-06-11T16:17:59+00:00

In my database, I have a parent and child tables. For example, parent table

  • 0

In my database, I have a parent and child tables.
For example, parent table contains last name and address, and child table contains last and first name.
There is a foreign key, so that a row in child table must have corresponding last-name in parent table.

When I read those two tables using 2 DataAdapter’s, and add those DataTable’s to DataSet, I’d like to print XML, that looks like this:

<parent_table>
  <last_name>Smith</last_name>
  <address>111 Hi Street, Bye city</address>
  <child_table>
    <last_name>Smith</last_name>
    <first_name>Ann</first_name>
  </child_table>
  <child_table>
    <last_name>Smith</last_name>
    <first_name>Bob</first_name>
  </child_table>
</parent_table>

However, at present I’m getting two tables printed separately:

<parent_table>
  <last_name>Smith</last_name>
  <address>111 Hi Street, Bye city</address>
</parent_table>
<child_table>
  <last_name>Smith</last_name>
  <first_name>Ann</first_name>
</child_table>
<child_table>
  <last_name>Smith</last_name>
  <first_name>Bob</first_name>
</child_table>

Is there a way to achieve (hopefully using DataSet.WriteXML()) my desired output?

I tried adding ForeignKeyConstraint, and tried adding DataRelation, but neither changed the output.

Disclaimer: the above was hand-written, so please excuse if there’s an error in XML. The actual tables contain better foreign key than ‘last-name’.

  • 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-11T16:18:01+00:00Added an answer on June 11, 2026 at 4:18 pm

    From Writing DataSet Contents as XML Data (ADO.NET):

    When writing an XML representation of a DataSet that contains
    DataRelation objects, you will most likely want the resulting XML to
    have the child rows of each relation nested within their related
    parent elements. To accomplish this, set the Nested property of the
    DataRelation to true when you add the DataRelation to the DataSet. For
    more information, see Nesting DataRelations (ADO.NET).

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

Sidebar

Related Questions

I have a database table with parent child relationships between different rows. 1 parent
I have two tables in an MS SQL Server 2005 database, parent and child,
Ok, I have three tables. The parent table is Listings and two child tables
I have a pair of tables in an Oracle database with a one-to-one parent-child
I have two tables Parent and Child. Both tables have a primary key MyDate
I have some Oracle tables that represent a parent-child relationship. They look something like
I'm having a problem with LINQ. I have 2 tables (Parent-child relation) Table1: Events
Example: I have two tables in my database called classA and classB , and
Supposing these are my parent and my child objects: Parent: @Entity @Table( name =
Suppose I have two tables in a parent - child relationship. Let's call them

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.