By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,953 Members | 1,143 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,953 IT Pros & Developers. It's quick & easy.

How to pass back recordset from inprocess COM object cleanly?

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.