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

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

I am debugging some legacy code:

xmlDoc.DataSet.Tables["table"].Rows.Add(row);
 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.

0
pillmill
Asked:
pillmill
  • 2
1 Solution
 
_eeCommented:
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
results.Tables[0].Columns.Add(column);

Open in new window

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

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