Passing Recordset from C# COM to VBScript
-
I am working on a COM dll in C# that needs to pass an ADODB recordset back to the calling VBScript. I believe I have everthing setup correctly, as the calls work, and it looks like a recordset is returned, however, the recordset is null or closed. What is the trick to passing a recordset back from C#? The Call: Set rs = CreateObject("Interface") rs.Init "System", "ODBC", "user", "pass", "database", "server" retVal = rs.DataImport("value") C#: using ADODB; [Guid("C3C26A94-9639-43c4-B59C-E245C8A68D44")] [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] public interface iInterface { [DispId(1)] bool DataExport(string OrderNumber, string TrackingNumber, decimal Freight, decimal Weight, string ShipDate, string ShipVia, string MiscNum); [DispId(2)] bool DataVoid(string OrderNumber, string TrackingNumber, decimal Freight, decimal Weight, string MiscNum); [DispId(3)] Recordset DataImport(string OrderNumber); [DispId(4)] void Init(string nameVal, string odbcVal, string userVal, string passVal, string dbVal, string srvVal); } [Guid("EF8369F0-CF42-40b1-B3F3-0EC54CE73FF4")] [ClassInterface(ClassInterfaceType.None)] [ProgId("Interface")] public class PSIHeader:iInterface { public Recordset DataImport(string OrderNumber) { //misc stuff - create connection, query etc... //Recordset creation and return rs.CursorLocation = CursorLocationEnum.adUseClient; rs.Open(query.ToString(), cn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockOptimistic, -1); return rs; } } I have been using regasm to register the type library. Thanks