Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to load a DataTable (SAPbouiCOM.DataTable) from a .Net DataTable using XML

Hello everyone!


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

                dAdapter.Fill(dt)

                dt.TableName = "CargaMasiva"

                Dim writer As New System.IO.StringWriter()

                dt.WriteXml(writer, XmlWriteMode.WriteSchema, False)

                Dim sXMLdt As String = writer.ToString()

              

                '-- SAPbouiCOM.DataTable

                DataTable.Clear() 

                'DataTable.LoadSerializedXML(SAPbouiCOM.BoDataTableXmlSelect.dxs_All, sXMLdt)

Thank you!

replied

Hi Gabriel,

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.

Kind Regards,

Owen

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question