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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:31:45+00:00 2026-05-25T06:31:45+00:00

Background Here is my issue. Earlier in the course of my program a System.Data.DataSet

  • 0

Background
Here is my issue. Earlier in the course of my program a System.Data.DataSet was serialized out to a file. Then sometime later the data set schema was changed in the program, specifically a column was added to one of the tables.

This data set has been created using VS and C#, so it has all the properties able to access the rows and columns by name (through the Microsoft generated code). It has all the files (.xsd, .cs, etc.) that VS needs to know what the data set looks like and the names therein.

The file is loaded and saved through XML Serialization. This causes an issue now because when I deserialize the old file it loads in the data related to the old schema. This works for the most part, but the object that is created (the data set) has everything but the column that was added later. So, when trying to access the new column it fails because the deserialization did not know about it and the entire column winds up being null.

This now causes more issues because it throws an exception when trying to access that column (because it’s null) through the properties of the data set.

Question
My question is, can I somehow add in the column after deserialization? I apparently need to add it so that it complies with the Microsoft generated code because doing this:

myDataSet.myTable.Columns.Add("MyMissingColumn");

…does not add the column it needs. It may add a column, but the row property myDataRow.MyMissingColumn returns null and errors out.

Do I need to somehow copy the new schema into this object? Again, the only reason this is failing is because the old file was serialized using the old schema.

Any suggestions are appreciated.

  • 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-25T06:31:46+00:00Added an answer on May 25, 2026 at 6:31 am

    Why don’t you load the schema from the new schema file, and then load the old data. Provided your column allows nulls it should be fine.

    DataSet data = new DataSet();
    data.ReadXmlSchema(schemaFile);
    data.ReadXml(dataFile, XmlReadMode.IgnoreSchema);
    

    Otherwise just add it on the fly:

     if (!data.Tables[0].Columns.Contains("SomeId"))
     {
        var column = new DataColumn("SomeId", typeof(int));
        // give it a default value if you don't want null
        column.DefaultValue = 1;
        // should it support null values?
        column.AllowDBNull = false;
        data.Tables[0].Columns.Add(column);
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have another issue here. Our app starts out with a tab activity. But, before
A little background here: I know what a data warehouse is , more or
I have a bit of a complex issue with a CSS background. Check out
I'm having a stupid css issue I can't seem to figure out. Here is
I have an Ul of item. I want to alternate there background color here
I have this query which works correctly in MySQL. More background on it here
Here's some background on what I'm trying to do: Open a serial port from
Here is an example of what I'd expect: Input: a { background: red; }
Total noob question, but here. CSS .product__specfield_8_arrow { /*background-image:url(../../upload/orng_bg_arrow.png); background-repeat:no-repeat;*/ background-color:#fc0; width:50px !important; height:33px
I'm trying to run some commands in paralel, in background, using bash. Here's what

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.