PC Review


Reply
Thread Tools Rate Thread

DataSet.ReadXml

 
 
keikoo
Guest
Posts: n/a
 
      20th Jun 2006
Hi, I,m trying to fill a DataSet with a xml file, so I pretend to use
the ReadXml method.
The .xsd file is defined, and the fields of the xml file have the same
name and type than the DataTable inside the DataSet.

the method is invoked in than way:

System.Xml.XmlNodeReader _xmlreader=new
System.Xml.XnodeReader(XmlDocument);
_dataset.ReadXml(_xmlreader, System.Data.XmlReadMode.ReadSchema);
_xmreader.Close();

The code is executed without exceptions, but the datatable remains the
same, no rows were added. If I change the reading options to
InferSchema, an exception is thrown because it tries to create new
columns with the same name as existing ones, so I think, the schema is
well created with the correct fields, the same as the xml file.

If I change the reading option to IgnoreSchema I have the same result
than with InferSchema.
Anyone knows what I'm doing wrong?. I've got no much idea about xml
schemas.

Thanks in advance.

 
Reply With Quote
 
 
 
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      20th Jun 2006
Hi,


Did you check if a new table was created?

I have never read XML to an already created table, so the only thing I can
assure you is that it does work when the dataset is empty.

Did you see this in MSDN:
If the XSD schema for a DataSet includes a targetNamespace, data may not be
read,


--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


"keikoo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi, I,m trying to fill a DataSet with a xml file, so I pretend to use
> the ReadXml method.
> The .xsd file is defined, and the fields of the xml file have the same
> name and type than the DataTable inside the DataSet.
>
> the method is invoked in than way:
>
> System.Xml.XmlNodeReader _xmlreader=new
> System.Xml.XnodeReader(XmlDocument);
> _dataset.ReadXml(_xmlreader, System.Data.XmlReadMode.ReadSchema);
> _xmreader.Close();
>
> The code is executed without exceptions, but the datatable remains the
> same, no rows were added. If I change the reading options to
> InferSchema, an exception is thrown because it tries to create new
> columns with the same name as existing ones, so I think, the schema is
> well created with the correct fields, the same as the xml file.
>
> If I change the reading option to IgnoreSchema I have the same result
> than with InferSchema.
> Anyone knows what I'm doing wrong?. I've got no much idea about xml
> schemas.
>
> Thanks in advance.
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ReadXml() method: standard DataSet vs. typed DataSet MikeOtown Microsoft ADO .NET 0 6th Dec 2007 05:15 PM
DataSet.ReadXml C Glenn Microsoft C# .NET 2 29th Nov 2005 01:04 PM
DataSet.ReadXML =?Utf-8?B?V2FsdA==?= Microsoft VB .NET 2 28th Jul 2005 12:32 AM
Re: does DataSet.ReadXml() clear current table information on DataSet CrunkByte Microsoft Dot NET Framework 0 21st May 2005 03:11 AM
Possible Bug in DataSet.ReadXml() Michelle Weber Microsoft ADO .NET 1 24th Dec 2003 06:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:01 AM.