cancel
Showing results for 
Search instead for 
Did you mean: 

Class into an XML file into a DataSet vs. Reflection into a DataTable

Former Member
0 Kudos

In order to serialize a class (SystemSetup) and load an XML file into a datatable and then a dataset I must:

1. Create an .XSD file using the XSD SDK tool.

2. DataTable.LoadSchemaFile

3. DataTable.LoadXml

4. Then add the datatable to a dataset.

Is this correct?

Another method using Reflection.

Reflect the SystemSetup class into a datatable.

Push the datatable->dataset to the crystal report.

Will this work?

Which one is preferable? Thx.,

Ajay

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

NOWHERE can I find the details on how to create a datatable from an XML file. Nor can i find it on these forums.

The current problem is when I use XSD with the /l:VB it converts the entire XML file elements to type string.

Any help will be greatly appreciated.

Sincerely,

Ajay

Former Member
0 Kudos

OK, i figured this much out:

Dim ds As New DataSet
        Dim myXmlReader As New System.Xml.XmlTextReader("C:\SystemSetup.xml")
        ds.ReadXml(myXmlReader, XmlReadMode.InferTypedSchema)
        mydatatable = ds.Tables(0)

Answers (2)

Answers (2)

Former Member
0 Kudos

I had to manually change the data types even with Strong Type Inference option. Don't know of an alternative.

Edited by: Ajay Shah on Jan 28, 2009 10:37 PM

Former Member
0 Kudos

null

Edited by: Ajay Shah on Jan 28, 2009 10:37 PM