xmlDoc.DataSet.Tables.Rows.Add(row) ?

Posted on 2008-11-19
Last Modified: 2013-11-18
I am debugging some legacy code:

 row["pix"] = (byte[])reader.GetValue(0);

The problem is that the element "pix" does not occur within
the .xsd document. I need to insert the values of reader.GetValue(0)
into an XML document, in base64 format. The code
seems to execute correctly, but generates an unhandled exception
in the debugger. Is it possible to add an element( a column) to
a DataSet and then read values into it ? This seems to be
what the code is doing.

Question by:pillmill
    LVL 3

    Accepted Solution

    Yes, it is.  Here's some code as an example (which should work).
    // Get the dataset from whatever source you are using.
    DataSet dataset = getDataSet();
    // Create the column
    DataColumn column = new DataColumn("ColumnName");
    column.DataType = typeof(int);
    column.DefaultValue = 0;
    // Add the newly created column to the DataSet

    Open in new window

    LVL 3

    Expert Comment

    In the above code "results" should be "dataset."  Sorry about the mixup.

    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System ( introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
    The task of choosing a web design company to build a website for your business should never be taken in a light manner. Provided the fact that your website will act as a representative to your business and will be responsible for imposing an online …
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
    The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now