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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:28:51+00:00 2026-05-29T19:28:51+00:00

I am reading in an XML file into a Dataset, then adding a new

  • 0

I am reading in an XML file into a Dataset, then adding a new column, then assigning a value to each row in that column.

My program creates the new column and I can see that it has the BitmapImage datatype by looking at it in the debug screen while its running and using a messagebox to toString its datatype.

But when i try to assign something to that row’s column, it remains as ‘{}’ and when I attempt to use it it gives the the error ‘Unable to cast type DBNull to BitmapImage’;

ItemDS = new DataSet();
ItemDS.ReadXml(homeFolder + @"Items.xml", XmlReadMode.InferSchema);
ItemDS.Tables[0].Columns.Add("pic", typeof(BitmapImage));
MessageBox.Show(ItemDS.Tables[0].Columns[5].DataType.ToString());
foreach (DataRow theRow in ItemDS.Tables[0].Rows)
{
    try
    {
        theRow.ItemArray[5] = (SquareImageFromFile(NewDeployFolder + @"assets\images\items\" + theRow.ItemArray[3].ToString(), 120));
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.ToString());
    }
    combItem.Items.Add(theRow.ItemArray[0]);
}

When I run the assignment row, no error comes up, but nothing happens to the item array after the line is run.

  • 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-29T19:28:53+00:00Added an answer on May 29, 2026 at 7:28 pm

    I haven’t used DataTable much, but I’d expect ItemArray to make a copy of the data, rather than returning a “live” array which the DataRow tracks. I wouldn’t really have expected that to work. Try just setting the value via the indexer:

    theRow[5] = (SquareImageFromFile(NewDeployFolder + @"assets\images\items\" + 
                                     theRow[3].ToString(), 120));
    

    ItemArray is really meant to get or set values in bulk, rather than for a single value.

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

Sidebar

Related Questions

I am reading an XML file into a DataSet and need to get the
I am reading an xml file using javascript and then I need to submit
While implementing XML file reading/writing in my application I saw that when I call
I am taking an XML file and reading it into various strings, before writing
I'm reading data from XML files into a strong typed DataSet . The data
I've got a fairly big XML file that I need to parse into a
I'm reading an xml file with PHP and pulling it into jQuery via a
I use SimpleXML to save a simple POJO into XML file and then read
I am reading IPaddress from xml file and I put it into IPaddress.parse() and
I am reading an XML file and reorganizing the desired data into Python data

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.