Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 983
  • Last Modified:

Return ADO recordset from a Delphi DLL

Can any one please help me.  Is it possible to return an ADO recordset from a delphi compiled DLL to a VB application?  I tried something like the following but the VB app just crashes when I call the function.
__________________________
library dlltest;

uses SysUtils, Classes, Dialogs, AdoRecordset, oleServer, Ado21Int, AdoConnection, AdoConsts, AdoUtils, AdoCommand;

function GetRecordSet : IRecordset; export; stdcall;
var o : TRecordSet;
begin
  o := TRecordset.Create(nil);
  GetRecordSet := o.Recordset; //IRecordSet interface
end;

exports GetRecordSet;

end.
___________________________________________

I'm not using ADOExpress.

What am I missing here? Any help would be greatly appreciated.  
0
kid_kaneda
Asked:
kid_kaneda
  • 3
  • 3
1 Solution
 
twalgraveCommented:
If the delphi DLL is a COM component, then YES.  What you do is add the DLL to the VB Project by going to "project...references" menu and selecting the compiled Delphi DLL.

Then you simply do this in VB:

dim oDelphiClass as YOURDELPHIPROJ.YourClass
0
 
kid_kanedaAuthor Commented:
Yeah thanks, I'm really trying to avoid using COM objects to do this for performance reasons. Is it possible to do this using a straight function call?  Surely there must be a way.
0
 
kid_kanedaAuthor Commented:
Yeah thanks, I'm really trying to avoid using COM objects to do this for performance reasons. Is it possible to do this using a straight function call?  Surely there must be a way.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
twalgraveCommented:
Can Delphi create a stdcall DLL?  If it can, create one and use it in VB like you would use a VB API call (Declare function YourFunction.  However, a class cannot be used like this.
0
 
kid_kanedaAuthor Commented:
Thanks for your help twalgrave but I have figured out why it wasn't working.  I needed to be returning the recordset as type oleVariant rather than IRecordset.
0
 
twalgraveCommented:
Glad you got it figured out!

Post a zero-point question in the community support topic area and ask for a PAQ/refund.  http://www.experts-exchange.com/Community_Support/

Make sure to give them the question number or url for this question so they know which question to work.
http://www.experts-exchange.com/Programming/Q_20522446.html
0
 
Computer101Commented:
Points refunded and placed in PAQ

Computer101
E-E Admin
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now