Click here to Skip to main content
15,888,065 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI, i'm writing the following code.
VB
Dim dtTemp As DataTable = New DataTable("Temp")
dtTemp.Columns.Add("Sno")
dtTemp.Columns.Add("Name")
Dim dr As DataRow = dtTemp.NewRow()
dr(0) = 1
dr(1) = "Sairam"
dtTemp.Rows.Add(dr)
dr = dtTemp.NewRow()
dr(0) = 2
dr(1) = "temp"
dtTemp.Rows.Add(dr)
dtTemp.WriteXml("c:\temp.xml")

Dim dtXmlRd As DataTable = New DataTable("Temp")
dtXmlRd.ReadXml("c:\temp.xml")


While Reading this xml filoe i'm getting an error like
"DataTable does not support schema inference from Xml."

Please let me know at's the problem.
Posted
Updated 27-Mar-12 18:38pm
v2

1 solution

You should be able to use ReadXml on the DataTable instance if you first call ReadXmlSchema to pull in a schema describing the data. That is the reason you are getting this error.

VB
Dim ds As New DataTable
ds.TableName = "TableName"
ds.ReadXmlSchema("e:\schema.xsd")
ds.ReadXml("e:\schema.xml")
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900