0

I'm wondering if using a stream would be faster to read an XML file and then insert into SQLCE (as opposed to reading the data from a file). So, I tried this code:

DataSet dset = new DataSet("New DataSet");
System.IO.FileStream streamRead = new System.IO.FileStream(filePathName, System.IO.FileMode.Open);
dset.ReadXml(streamRead);

...from here: http://msdn.microsoft.com/en-us/library/55hehd8c(v=vs.80).aspx

...but get these compile errors:

"Argument '1': cannot convert from 'System.IO.FileStream' to 'System.Xml.XmlReader'" -and: "The best overloaded method match for 'System.Data.DataSet.ReadXml(System.Xml.XmlReader)' has some invalid arguments"

Is it because the earliest example (the link above) is for .NET 2.0, and I am stuck with 1.0? IOW, the stream overload was not available in 1.0?

UPDATE

I also wanted to test this:

StringReader sr = new StringReader(filePathName);
DataSet dset = new DataSet("duckBills");
dset.ReadXml(sr);

...from here: http://knowdotnet.com/articles/datasetreadxml.html, but got a similar err msg; I think being stuck on .NET 1.0 is likely my problem...

ctacke
  • 66,480
  • 18
  • 94
  • 155
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
  • At the bottom of the MSDN page you linked it says "Version Information ... .NET Compact Framework ... Supported in: 2.0" so I think you're out of luck if you are limited to 1.1 – Roger Rowland May 28 '13 at 19:22
  • 1
    Ah yes; I reckon my suspicion was correct. "Dang it!" as Kip Dynamite said in response to the Tupperware splintering into untold sharp shards. – B. Clay Shannon-B. Crow Raven May 28 '13 at 19:25

1 Answers1

1

Use

new XmlTextReader(Stream)

DataSet dset = new DataSet("New DataSet");
using (System.IO.FileStream streamRead = new System.IO.FileStream(filePathName, System.IO.FileMode.Open))
{
    XmlTextReader reader = new XmlTextReader(streamRead);
    dset.ReadXml(reader);
}
John Saunders
  • 160,644
  • 26
  • 247
  • 397