Solved

STL list of microsoft ADODB recordsets

Posted on 2002-06-12
7
305 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Focus not getting shifted out of  editbox 2 57
typedef std::deque<BYTE> ByteVector is broken in vs2012 23 82
Beginner to Unreal Engine 4 5 62
VS2015 Redefinition errors 4 30
  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 …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now