?
Solved

Return ADO recordset from a Delphi DLL

Posted on 2003-02-20
7
Medium Priority
?
966 Views
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;
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
Comment
Question by:kid_kaneda
[X]
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
7 Comments
 
LVL 16

Expert Comment

by:twalgrave
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
0
 

Author Comment

by:kid_kaneda
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.
0
 

Author Comment

by:kid_kaneda
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.
0
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

by:twalgrave
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.
0
 

Author Comment

by:kid_kaneda
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.
0
 
LVL 16

Expert Comment

by:twalgrave
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.
http://www.experts-exchange.com/Programming/Q_20522446.html
0
 
LVL 1

Accepted Solution

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

Computer101
E-E Admin
0

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