• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1563
  • Last Modified:

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

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.

  • 2
1 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

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now