Link to home
Start Free TrialLog in
Avatar of asaflahv1
asaflahv1

asked on

STL list of microsoft ADODB recordsets

What i'm trying to do is, creating a linked list using the STL which contains recordsets.

Can you please send me a code sample of how to do it?

Here is what i have been trying to do on my main function:
     CoInitialize(NULL);
     {
      // TODO: Place code here.
     HRESULT hr = 0;
     _ConnectionPtr pCon;
     hr = pCon.CreateInstance("ADODB.Connection");
     hr = pCon->Open(L"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\Program\\Database\\DB.mdb;Persist Security Info=False",L"",L"",0);
     
     _RecordsetPtr pRs;
     hr = pRs.CreateInstance("ADODB.Recordset");
     hr = pRs->put_CursorLocation(adUseClient);
     //hr = pRs->Open (L"select * from tblStatuses",_variant_t((IDispatch *) pCon, true),adOpenDynamic,adLockBatchOptimistic,0);
     hr = pRs->Open (L"select * from tbl",_variant_t(pCon.GetInterfacePtr(), true),adOpenDynamic,adLockBatchOptimistic,0);
     LISTRsPtrs lst;
     lst.insert(lst.end(),&pRs.GetInterfacePtr());
     }
     CoUninitialize();

AND IT DOESN'T WORK!
PLEASE HELP!! :-)

Thanks allot,

Asaf Lahav
ASKER CERTIFIED SOLUTION
Avatar of ambience
ambience
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nietod
nietod

>>   lst.insert(lst.end(),&pRs.GetInterfacePtr());

shouldn't that be

   lst.insert(lst.end(),pRs->GetInterfacePtr());

A) pRs is a pointer, not an objcect, so you need -> instead of the . operator
B) you need to store pointers in this list, not pointers to pointers.
Avatar of asaflahv1

ASKER

Eventually i succeeded storing a list of recordsets.
Unfortunately it wasn't any of the suggestions you supplied to make it work.

the problem was that i defined a list that was declared of _RecordsetPtr template.
And i guess the smart pointer had a problem with that.
So I simply changed the declaration and it all works.

Thanks allot for the effort anyway,

Asaf Lahav.

p.s, i'm going to give the points to ambience because his answer was the closest.

Thanks allot,
C'ya later aligator
You should realize that the reason that none of the answers were good was that we needed more information.  We asked you questions and never got any answers.   We just didn't know enough about your list and other aspects of the code to understand the problem.  I'm glad you got a solution, but it might have been faster and easier for you if you had responded.

I should also add that providing ambience with a "C" is a bit harsh.   She (I think it is "she", right?) is a good expert and probably has at least a B, if not A, average.   To give her a C for circumstances beyone her control (insufficient information) is a bit unfair  Many experts would prefer to receive no grade, rather than a bad grade..
>> She (I think it is "she", right?)

Now that i think is a direct assault on my sexual identity ... hey!

OK here, https://www.experts-exchange.com/cplusprog/Q.20304017.html, you can find out whether am a he or a he !!

>> Many experts would prefer to receive no grade, rather than a bad grade..

Though am not a die hard for points but this is Absolutely Absolutely true, and has come right from the core of my heart !!!!

I think there should be an option of "No Thank You!" to address such situations, boy i would love that. Is this in the agenda ?????????

I certainly cannot understand why "COMMENTS" are awarded C grade, a proposed answer getting a C or a B is understandable (maybe) but a comment ??. its just a comment not a "request for points", and if someones not satisfied then he/she can say so or can ask for more information.

I really hate this practice but theres nothing that i can do.

>> Unfortunately it wasn't any of the suggestions you supplied to make it work.

You could've asked for deletion of this question !
>>  think there should be an option of "No Thank You!" to address such
>> situations, boy i would love that. Is this in the agenda ?????????
Not as easy, but you can post a request in the customer service topic area to have them delete this or maybe up the grade.
ambience and nietod,

I'm truely sorry.

I never ment to hurt anyones feelings...
I honnestly and truely appreciate the effort you all made to help me with my dillema.

I simply succeeded in solving this before any affective advice was given...
So i thought it would be better to atleast award one of you guys for the effort and thought you would be glad to receive those points...

Anyhow, I apologize people...