Connecting Tech Pros Worldwide Forums | Help | Site Map

How to pass back recordset from inprocess COM object cleanly?

Rufus DeDufus
Guest
 
Posts: n/a
#1: Nov 12 '05
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






Robert
Guest
 
Posts: n/a
#2: Nov 12 '05

re: How to pass back recordset from inprocess COM object cleanly?


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" <sporkmeupScotty@hotmail.com> wrote in message
news:100s9ah60q427d3@corp.supernews.com...[color=blue]
> This is more a matter of programming taste ...
> I have a Database DLL that is calling into Access through OLEDB, and[/color]
exposes[color=blue]
> 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
>
>
>
>
>[/color]


Closed Thread