i have dataset named ds in want load xml.
so use function ds.readxml();
the paramter readxml function xmltextreader object.
if pass object
ds.readxml(new xmltextreader(application.startuppath + "\\mydatasource.xml")); the dataset loaded. later on, want close xmltextreader object. although didn't declared name like
xmltextreader reader = new xmltextreader(somepath); how can close reader???
you'll need use variable, otherwise can't access it.
and while @ it, use using statement:
string path = path.combine(application.startuppath, "mydatasource.xml")); using (var reader = new xmltexttreader(path)) { ds.readxml(reader); } the using statement automatically calls dispose on reader when exiting scope of using statement.
note: should use path.combine instead of concatting path yourself. saves lot of trouble.
Comments
Post a Comment