Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > VS.NET 2002/2003
|
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 18th, 2005, 09:11 AM
Registered User
 
Join Date: Jul 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default COM .NET Interop - How to return a DataTable from

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

jhpe
 
Old July 19th, 2005, 01:29 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You need to return something that is friendly to COM. Within .NET you could reference the ADODB libraries, create an ADODB.RecordSet and return that. Or you could return a multidimensional array (like when you call ADODB.RecordSet.GetRows()). COM should be happy to handle that as well.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
C# Interop problem with ASP.Net jitumandalia Visual Studio 2005 0 January 23rd, 2007 01:41 AM
Return datatable from a webmethod josemanjusha ASP.NET 2.0 Basics 0 September 21st, 2006 07:52 AM
Return DataSet / DataTable from Stored Procedure ashu_from_india ADO.NET 3 March 20th, 2005 05:39 AM
Return DataTable from Web Method Function kasie ASP.NET 1.0 and 1.1 Basics 2 February 11th, 2004 06:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.