473,395 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to pass back recordset from inprocess COM object cleanly?

This is more a matter of programming taste ...
I have a Database DLL that is calling into Access through OLEDB, and exposes
functions like AddPerson(STRING szFirstName, STRING szLastName, INT uAge)
etc.

Now I want to interrogate it in this manner:
GetPersonsBetweenAges(INT uLowerAge, INT uUpperAge, ..),

and get back a recordset of Persons.

What is the "nice" way to implement?
(1) Pass back a naked pointer to the recordset:

GetPersonsBetweenAges(uLowerAge, uUpperAge, Persons **ppPeople),

allocate the memory to the recordset in the DLL, and expect the caller to
free it. Messy. Caller has to free memory, much type information has to
cross object bounds.

(2) Return pointer to IEnumXXX interface:

GetPersonsBetweenAges(uLowerAge, uUpperAge, IEnumPersons **ppPeople),

Seems better but still need to manage object lifetime, and I can get a lot
of IEnumXXX interfaces to deal with ....

What is the "nice" c-plus-plussie way to pass a recordset across an object
boundary?

Thanks.

Eric

Nov 12 '05 #1
1 1781
Well, I'm not a C expert, but couldn't you use a Typed Pointer to a
Recordset?

http://www.codeguru.com/atl/ATLnADO.html

Microsoft has a novel approach in ADO 2.8. The Microsoft Visual C++
Extensions for ADO associate, or bind, fields of a Recordset object to C/C++
variables.

http://msdn.microsoft.com/library/de...gramming_8.asp

"Rufus DeDufus" <sp*************@hotmail.com> wrote in message
news:10*************@corp.supernews.com...
This is more a matter of programming taste ...
I have a Database DLL that is calling into Access through OLEDB, and exposes functions like AddPerson(STRING szFirstName, STRING szLastName, INT uAge)
etc.

Now I want to interrogate it in this manner:
GetPersonsBetweenAges(INT uLowerAge, INT uUpperAge, ..),

and get back a recordset of Persons.

What is the "nice" way to implement?
(1) Pass back a naked pointer to the recordset:

GetPersonsBetweenAges(uLowerAge, uUpperAge, Persons **ppPeople),

allocate the memory to the recordset in the DLL, and expect the caller to
free it. Messy. Caller has to free memory, much type information has to
cross object bounds.

(2) Return pointer to IEnumXXX interface:

GetPersonsBetweenAges(uLowerAge, uUpperAge, IEnumPersons **ppPeople),

Seems better but still need to manage object lifetime, and I can get a lot
of IEnumXXX interfaces to deal with ....

What is the "nice" c-plus-plussie way to pass a recordset across an object
boundary?

Thanks.

Eric


Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Malcolm Cook | last post by:
Hi, I've created and installed a custom UDF to populate my combobox, and have defined it per :...
3
by: JingleBEV | last post by:
Hi all, I am trying not to use global variable to maintain data consistency. Some procedures and functions will require to pass the recordset object for processing and functions may also return...
3
by: Lyn | last post by:
Hi, I have been experiencing a problem passing a LIKE statement in the WHERE argument of a DoCmd.Openform statement. I have posted that issue separately. However, in an attempt to work around...
7
by: Zlatko Matić | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
3
by: Andrew Mueller | last post by:
Hello, I tried this question prior and got no response, so thought I would try to explain differently.. I am not sure which type of object to pass between a VB 6.0 ActiveX dll and C#. I am...
2
by: martin | last post by:
Hi, I am just about to deploy my production application on a win2k server with two processors. I have been reading that inprocess session state is not the best method for multi processor...
3
by: Ted Ngo | last post by:
I want to use the .net Web Service to create a function and return the datas (RecordSet). And want to retrived those data on the classic ASP. Does any body have some example of this. How to create...
5
by: slowmotiongenius | last post by:
All- I have established an adodb recordset in my code-behind, and I need to pass it to the aspx file. I can't seem to figure out if there is a way to do this. I see you can pass a string over...
5
by: techbuddha | last post by:
Hi new to the forum and visual basic. I am attempting to fix a migration of excel to access. The excel sheets where simple copied as is into access. for example one table lists the academic...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.