Link to home
Start Free TrialLog in
Avatar of kid_kaneda
kid_kaneda

asked on

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.  
Avatar of twalgrave
twalgrave

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
Avatar of kid_kaneda

ASKER

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.
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.
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.
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.
Glad you got it figured out!

Post a zero-point question in the community support topic area and ask for a PAQ/refund.  https://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.
https://www.experts-exchange.com/questions/20522446/Return-ADO-recordset-from-a-Delphi-DLL.html
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial