Hi everyone,

I have a question regarding DataSets and the WriteXml method.
Specifically, I'm having trouble writing out my DataSet, then reading the
contents back in to an XmlDataDocument.

For instance, my code reads like this:

/////////////////////////

StringWriter l_strWrite = new StringWriter();
XmlDataDocument l_XMLDocument = new XmlDataDocument();

//MyDataSet is a pre-existing DataSet
MyDataSet.WriteXml(l_strWrite,System.Data.XmlWriteMode.WriteSchema);
l_XMLDocument.LoadXml(l_strWrite.ToString());

////////////////////////

No errors when I run this, however when all is said and done, my
XmlDataDocument's DataSet member has zero tables, whereas the original
("MyDataSet") has one table in its collection. Something's not right--
maybe I'm not saving the DataSet correctly via WriteXml()?

I realize the XmlDataDocument class has a DataSet member that I can assign
to, however in my code I can't just simply set things equal to
MyDataSet....I'm trying to write out the DataSet to a string then pass it
around from one section of my program to another. Only later on will I
create my XmlDataDocument.

Maybe I should create a temporary DataSet from my string when the time
comes, then assign it to my XMLDataDocument's DataSet member? Sounds like a
hack, but maybe it's an option. I don't know.

If you have any suggestions or ideas on how I can correctly write out/read
in my DataSet to an XMLDataDocument, I'd be glad to hear them. Thanks very
much.

-Jim

Re: WriteXml & XmlDataDocument questions by Val

Val
Fri Nov 12 20:44:37 CST 2004

Hi Jamie,
I think you have to use
/////////////
UrDataSet.ReadXml(<source>,System.Data.XmlReadMode.<mode>);
/////////////
instead of LoadXml to load the dataset back in.
Val


"Jamie Owens" <asdfsklw@nowhere.com> wrote in message
news:ei2WQKSyEHA.3676@TK2MSFTNGP10.phx.gbl...
> Hi everyone,
>
> I have a question regarding DataSets and the WriteXml method.
> Specifically, I'm having trouble writing out my DataSet, then reading the
> contents back in to an XmlDataDocument.
>
> For instance, my code reads like this:
>
> /////////////////////////
>
> StringWriter l_strWrite = new StringWriter();
> XmlDataDocument l_XMLDocument = new XmlDataDocument();
>
> //MyDataSet is a pre-existing DataSet
> MyDataSet.WriteXml(l_strWrite,System.Data.XmlWriteMode.WriteSchema);
> l_XMLDocument.LoadXml(l_strWrite.ToString());
>
> ////////////////////////
>
> No errors when I run this, however when all is said and done, my
> XmlDataDocument's DataSet member has zero tables, whereas the original
> ("MyDataSet") has one table in its collection. Something's not right--
> maybe I'm not saving the DataSet correctly via WriteXml()?
>
> I realize the XmlDataDocument class has a DataSet member that I can assign
> to, however in my code I can't just simply set things equal to
> MyDataSet....I'm trying to write out the DataSet to a string then pass it
> around from one section of my program to another. Only later on will I
> create my XmlDataDocument.
>
> Maybe I should create a temporary DataSet from my string when the time
> comes, then assign it to my XMLDataDocument's DataSet member? Sounds like
> a
> hack, but maybe it's an option. I don't know.
>
> If you have any suggestions or ideas on how I can correctly write out/read
> in my DataSet to an XMLDataDocument, I'd be glad to hear them. Thanks
> very
> much.
>
> -Jim
>
>
>
>



Re: WriteXml & XmlDataDocument questions by Val

Val
Fri Nov 12 20:51:30 CST 2004

Oops, didnt pay pay attention to "XmlDataDocument", oh well.

"Val" <val666@gmail.com> wrote in message
news:%23FsM5qSyEHA.3844@TK2MSFTNGP12.phx.gbl...
> Hi Jamie,
> I think you have to use
> /////////////
> UrDataSet.ReadXml(<source>,System.Data.XmlReadMode.<mode>);
> /////////////
> instead of LoadXml to load the dataset back in.
> Val
>
>
> "Jamie Owens" <asdfsklw@nowhere.com> wrote in message
> news:ei2WQKSyEHA.3676@TK2MSFTNGP10.phx.gbl...
>> Hi everyone,
>>
>> I have a question regarding DataSets and the WriteXml method.
>> Specifically, I'm having trouble writing out my DataSet, then reading the
>> contents back in to an XmlDataDocument.
>>
>> For instance, my code reads like this:
>>
>> /////////////////////////
>>
>> StringWriter l_strWrite = new StringWriter();
>> XmlDataDocument l_XMLDocument = new XmlDataDocument();
>>
>> //MyDataSet is a pre-existing DataSet
>> MyDataSet.WriteXml(l_strWrite,System.Data.XmlWriteMode.WriteSchema);
>> l_XMLDocument.LoadXml(l_strWrite.ToString());
>>
>> ////////////////////////
>>
>> No errors when I run this, however when all is said and done, my
>> XmlDataDocument's DataSet member has zero tables, whereas the original
>> ("MyDataSet") has one table in its collection. Something's not right--
>> maybe I'm not saving the DataSet correctly via WriteXml()?
>>
>> I realize the XmlDataDocument class has a DataSet member that I can
>> assign
>> to, however in my code I can't just simply set things equal to
>> MyDataSet....I'm trying to write out the DataSet to a string then pass it
>> around from one section of my program to another. Only later on will I
>> create my XmlDataDocument.
>>
>> Maybe I should create a temporary DataSet from my string when the time
>> comes, then assign it to my XMLDataDocument's DataSet member? Sounds
>> like a
>> hack, but maybe it's an option. I don't know.
>>
>> If you have any suggestions or ideas on how I can correctly write
>> out/read
>> in my DataSet to an XMLDataDocument, I'd be glad to hear them. Thanks
>> very
>> much.
>>
>> -Jim
>>
>>
>>
>>
>
>