COM .NET Interop - How to return a DataTable from NET to COM VB6

Hi, I need help here.. I have this problem.
I have COM VB6 that call a .NET class library, and this class library use the .NET SAP Conector to extract the information from SAP. I receive the information from SAP in a DataTable, the problem here is that I dont how to return this DataTable to VB6 COM.
I made a test, and I can return a String to COM and basic types, but I dont know how to do it with this DataTable.
Thanks for your help
I really appreciate.

Public Interface interfaceSapNet
Function Get_Z_YACV_READ_GINCOTABS(ByVal I_LAND As String, ByVal I_Z1DELN As String, ByVal I_Z1LONO As String, ByVal I_Z1LTCY As String, ByVal I_Z1MCU As String, ByVal I_Z1XSIA As String) As XXXXXXXX
End Interface

Public Class rfcFunctionsNetSap
Implements interfaceSapNet

Public Function Get_Z_YACV_READ_GINCOTABS(ByVal I_LAND As String, ByVal I_Z1DELN As String, ByVal I_Z1LONO As String, ByVal I_Z1LTCY As String, ByVal I_Z1MCU As String, ByVal I_Z1XSIA As String) As String _
Implements interfaceSapNet.Get_Z_YACV_READ_GINCOTABS

Dim DataTableSap As DataTable = New DataTable
Dim xmlString As String

' build the connection string (update this with your connection info)
Dim cs As String = "CLIENT=xxx USER=xxx PASSWD=xxx LANG=EN ASHOST=xxx SYSNR=0"

' construct the proxy with connection string
Dim proxy As New SAPProxy1(cs)

' create a sap table variable
Dim tableOutPut As New ZXX_GINCOTESTTable
' call the RFM method on the proxy
proxy.Z_Yacv_Read_Gincotabs(I_LAND, I_Z1DELN, I_Z1LONO, I_Z1LTCY, I_Z1MCU, I_Z1XSIA, "", tableOutPut)

//====================================================
//HERE IS THE PROBLEM, I DONT HOW TO RETURN THIS TABLE TO VB6
//====================================================
DataTableSap = tableOutPut.ToADODataTable
//====================================================

Return DataTableSap

End Function


[2012 byte] By [JHPE] at [2007-12-16]
# 1
JHPE,

There is no concept in COM that will map an ADO.NET datatable to an understandable structure and/or object. I would suggest you either re-write your middle tier component in .NET or if this is not feasible (which is quite common) you can look at a KB article that has been published on the support site that shows how to convert DataSet into the recordset XML and then this can be loaded by an ADODB.Recordset object. The article is at http://support.microsoft.com/default.aspx?scid=kb;en-us;316337. If you have any questions just ask.

Thanks,

Carl Perry
Program Manager ADO.NET
cperry@microsoft.com

CarlPerry-Microsoft at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...

.NET Development

Site Classified