Solved

STL list of microsoft ADODB recordsets

Posted on 2002-06-12
7
331 Views
Last Modified: 2009-12-16
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
0
Comment
Question by:asaflahv1
[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
  • 2
  • 2
7 Comments
 
LVL 22

Accepted Solution

by:
ambience earned 100 total points
ID: 7072441
What doesnt work ??
how are you declaring the list ?

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

This goes out of scope immediately after the closing brace, maybe that is why ? by any chance do you have a global lst that you try to populate ?

As a side note using  

lst.push_back(..);

achieves the same.

post some details about what is not working and how are you delaring the lst or typedefing it.
0
 
LVL 22

Expert Comment

by:nietod
ID: 7072462
>>   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.
0
 
LVL 1

Author Comment

by:asaflahv1
ID: 7077016
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
0
Technology Partners: 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 22

Expert Comment

by:nietod
ID: 7077050
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..
0
 
LVL 22

Expert Comment

by:ambience
ID: 7077194
>> She (I think it is "she", right?)

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

OK here, http://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 !
0
 
LVL 22

Expert Comment

by:nietod
ID: 7077855
>>  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.
0
 
LVL 1

Author Comment

by:asaflahv1
ID: 7077862
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...

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

738 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