By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,152 Members | 1,837 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,152 IT Pros & Developers. It's quick & easy.

Passing Recordset from C# to VBScript

P: n/a
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.InterfaceIsIDispatc h)]
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
{
//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
Mar 28 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.