M
MurdockSE
Greetings.
My Situation:
// I have an .xml file that I am reading into a dataset in the
following code -
DataSet ds = new DataSet("MyDataset");
ds.ReadXml(@"c:\data\"+cmyxmlfilename);
// I am then attempting to obtain a subset of that dataset to filter
the data as follows -
DataSet subSet = ds.Clone();
DataRow[] copyRows = ds.Tables[1].Select("`myStringField` > 19.99");
DataTable myTable = subSet.Tables[1];
foreach (DataRow copyRow in copyRows)
{
myTable.ImportRow(copyRow);
}
My Question:
When you read an XML file in this manner, how do you cast the columns
to another type for a SELECT filter expression?
For example, myStringField contains what is actually a "double", but in
string format, as the XMLRead method doesn't allow you to type the
resulting fields. How do I cast in a SELECT filter expression on a
dataset created from XML using ReadXML? I've attempted to cast the type
of the datacolumn in dataset "ds", but it errors out stating I cannot
change it after there is data in the dataset.... well, chicken or egg
flambe? How do I cast the column type prior to the SELECT filter
expression? Or is there a way in the Select method to call upon a cast?
I could not figure out a method that would work.
Thanks ahead of time,
Peter Robbins
"Oh, .NET is easy....... if you know how to do it".
My Situation:
// I have an .xml file that I am reading into a dataset in the
following code -
DataSet ds = new DataSet("MyDataset");
ds.ReadXml(@"c:\data\"+cmyxmlfilename);
// I am then attempting to obtain a subset of that dataset to filter
the data as follows -
DataSet subSet = ds.Clone();
DataRow[] copyRows = ds.Tables[1].Select("`myStringField` > 19.99");
DataTable myTable = subSet.Tables[1];
foreach (DataRow copyRow in copyRows)
{
myTable.ImportRow(copyRow);
}
My Question:
When you read an XML file in this manner, how do you cast the columns
to another type for a SELECT filter expression?
For example, myStringField contains what is actually a "double", but in
string format, as the XMLRead method doesn't allow you to type the
resulting fields. How do I cast in a SELECT filter expression on a
dataset created from XML using ReadXML? I've attempted to cast the type
of the datacolumn in dataset "ds", but it errors out stating I cannot
change it after there is data in the dataset.... well, chicken or egg
flambe? How do I cast the column type prior to the SELECT filter
expression? Or is there a way in the Select method to call upon a cast?
I could not figure out a method that would work.
Thanks ahead of time,
Peter Robbins
"Oh, .NET is easy....... if you know how to do it".