How to load a DataTable (SAPbouiCOM.DataTable) from a .Net DataTable using XML
I'm trying to load a DataTable from .Net SAPbouiCOM.DataTable (Cragado from an Excel file). I want to use XML to transfer data between DataTables, I know I can make this transfer through a loop, but it is not optimal method.
This is my code, but there is an error when executing the method LoadSerializedXML, apparently the XML generated from .Net DataTable is not in the correct format, any suggestions?
Dim dAdapter As New OleDbDataAdapter("Select * From [" & sHoja & "$]", cs)
Dim dt As New DataTable
dt.TableName = "CargaMasiva"
Dim writer As New System.IO.StringWriter()
dt.WriteXml(writer, XmlWriteMode.WriteSchema, False)
Dim sXMLdt As String = writer.ToString()
Owen Slater replied
The xml schemas for the .NET datatable and the UI API datatable are completely different so you'll have to do some sort of conversion. XSLT would be one way to achieve this. I've never tried but it's probably straightforward if you only need to write it for this specific conversion (ie where you already know the structure of both datasources) but more of a challenge if you want to create a generic method to convert any .NET datatable to a UI API datatable.