Hello,
I am trying to convert an existing datatable into an XML file. The datatable has many fields including the two most important ones:
parent_guid
current_guid
I want to create the XML out of this datatable with the relationship of these two columns. A simple WriteXml method does not solve my problem because I it does not relate these two columns.
I am trying to create a dataset and add relations to it, however, I have been unable to make it work since it is looking for two tables to create the relationship. Thus I tried just copying the same table and providing that but it does not work. This seems like a simple thing to do, and so I was looking for maybe a quick example of how to accomplish this.
I was actually trying something along these lines:
Public Shared Sub convertDTtoXML(ByVal dt As Data.DataTable)
Dim ds As New Data.DataSet
Dim dt1 As Data.DataTable = New Data.DataTable
dt1 = dt.Copy()
ds.Tables.Add(dt)
ds.Tables.Add(dt1)
ds.Relations.Add("parent_guid", _
New Data.DataColumn() {dt.Columns(1)}, _
New Data.DataColumn() {dt1.Columns(2)}, True)
dt.WriteXml(location)
Any help is appreciated!!!
Thank You!!
I am trying to convert an existing datatable into an XML file. The datatable has many fields including the two most important ones:
parent_guid
current_guid
I want to create the XML out of this datatable with the relationship of these two columns. A simple WriteXml method does not solve my problem because I it does not relate these two columns.
I am trying to create a dataset and add relations to it, however, I have been unable to make it work since it is looking for two tables to create the relationship. Thus I tried just copying the same table and providing that but it does not work. This seems like a simple thing to do, and so I was looking for maybe a quick example of how to accomplish this.
I was actually trying something along these lines:
Public Shared Sub convertDTtoXML(ByVal dt As Data.DataTable)
Dim ds As New Data.DataSet
Dim dt1 As Data.DataTable = New Data.DataTable
dt1 = dt.Copy()
ds.Tables.Add(dt)
ds.Tables.Add(dt1)
ds.Relations.Add("parent_guid", _
New Data.DataColumn() {dt.Columns(1)}, _
New Data.DataColumn() {dt1.Columns(2)}, True)
dt.WriteXml(location)
Any help is appreciated!!!
Thank You!!