Return ADO recordset from a Delphi DLL

Posted on 2003-02-20
Medium Priority
Last Modified: 2007-12-19
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;
  o := TRecordset.Create(nil);
  GetRecordSet := o.Recordset; //IRecordSet interface

exports GetRecordSet;


I'm not using ADOExpress.

What am I missing here? Any help would be greatly appreciated.  
Question by:kid_kaneda
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 16

Expert Comment

ID: 7987734
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

Author Comment

ID: 7992537
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.

Author Comment

ID: 7992582
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.
Independent Software Vendors: 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!

LVL 16

Expert Comment

ID: 7999685
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.

Author Comment

ID: 8017373
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.
LVL 16

Expert Comment

ID: 8017437
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.

Accepted Solution

Computer101 earned 0 total points
ID: 8024968
Points refunded and placed in PAQ

E-E Admin

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
Make the most of your online learning experience.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Suggested Courses

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question