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.
__________________________
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.
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.
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.
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.
ASKER
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Then you simply do this in VB:
dim oDelphiClass as YOURDELPHIPROJ.YourClass