I have been using MFC CRecordset CDatabase for some time. With VB I use ADO.
Well, I am starting a small new project and want to use different database access methods under VC++, such as ADO. But after looking through this site, does not look like many people use this.

?If I want to enhance my skill set, should I look into ADO or OLE under VC++ 6.0.
?If so, which one, and links to some tutorials.
?What about OLE DB consumer templates, what the hell is this?
?Are there wizards in VC++ 6.0 that help with integerating ADO such as with CRecordset class or is it all straight coding.

Back-end db is SQL server 7.0

Who is Participating?
DanRollinsConnect With a Mentor Commented:
ADO vs CRecordset:

With ADO and OLEDB, you use table/field names directly --  so your code looks about the same whether you are programming in VB, JavaScript, or C++ (of course C++ has all of that ugly COM overhead, as I've said).  And you can write very flexible SQL commands.  The data comes and goes as VARIENT data type which is very convenient for VB and JS, but awkward in C++.

With CRecordset, you let the framework transfer data between member variables and the database.  A VARCHAR data type comes in as an easy-to-use CString, etc.  The drawback is that there is a lot of 'inflexible' binding going on.  For instance, even if all you need is three columns, you will probably use a CRecordset that populates all member fields.  That means that there is a lot of data transfer going on that you don't need.

-- Dan
>>?If I want to enhance my skill set, should I look into ADO or OLE under VC++ 6.0.
Probably OLEDB since it is the coming wave.  But you will find more examples in MDSN and elsewhere for ADO.  Both are infinitely harder to use than CRecordset objects.

>>?Are there wizards in VC++ 6.0 that help with
>> integerating ADO such as with CRecordset class or is it
>> all straight coding.
All straight coding, and not much of it is easy.  If you use CRecordset, the tne ClassWizard makes named variables for each field of each table.  Change the table and the ClassWizard can update your object with a few clicks.

If you use ADO or OLEDB, you will be digging around all through your code to locate the changed spelling of the table/field name.  And the error won't occur unti runtime (then the data provider says "I've never heard of that field" and rejects the whole query.)

-- Dan
Incidently, here is the best code sample for ADO access that I've ever seen.  It is PERFECT because it does the bare minimum:

#include <stdio.h>
#include <afxdisp.h>
#import "c:\program files\common files\system\ado\msado15.dll" rename ("EOF","adoEOF") no_namespace

#define CREATEiNSTANCE(sp,riid) { HRESULT _hr =sp .CreateInstance( __uuidof( riid ) ); \
                                  if (FAILED(_hr)) _com_issue_error(_hr); }

#define RsITEM(rs,x) rs->Fields->Item[_variant_t(x)]->Value
#define UC (char *)
struct InitOle {
    InitOle()  { ::CoInitialize(NULL); }
    ~InitOle() { ::CoUninitialize();   }
} _init_InitOle_;       // Global Instance to force load/unload of OLE

void main(){
    _RecordsetPtr   spRS;
    _ConnectionPtr  spCON;
        spCON->ConnectionString = L"driver={sql server};SERVER=(local);Database=pubs;UID=sa; PWD=;";
        // spCON->ConnectionString =L"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=authors.MDB;DefaultDir=C:\\test;";
        spCON->Open( "", "", "", -1 );
        spRS->PutRefActiveConnection( spCON );
        spRS->Open("select au_lname, au_fname from authors",
               vtMissing, adOpenKeyset,
            adLockBatchOptimistic, -1
        while(spRS->adoEOF == false){
            printf("au_lname = %s  au_fname = %s \n",
                    UC _bstr_t(RsITEM(spRS,0L)),
                    UC _bstr_t(RsITEM(spRS,"au_fname"))
    catch( _com_error &e){
        _bstr_t bstrSource(e.Source());
        _bstr_t bs =  _bstr_t(" Error: ") + _bstr_t(e.Error()) + _bstr_t(" Msg: ")
            + _bstr_t(e.ErrorMessage()) + _bstr_t(" Description: ")
            + _bstr_t(e.Description());
        MessageBox(0,bs,bstrSource, MB_OK);

-- Dan
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

PaullkhaAuthor Commented:

Looks like no-one else disagrees.

When should one use ADO over the CRecordset object, since my reservations about ADO seem validated? I have seen it used in some examples on the web, but are there any compelling reasons to use it?
This question is current, others are not and need your attention.  ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101, Netminder or Mindphaser will return to finalize these if they are still inactive in 7 days.  Experts, please post closing recommendations before that time.

Below are your open questions as of today.  Questions which have been inactive for 21 days or longer are considered to be abandoned and for those, your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.

Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.  

Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added.  When you grade the question less than an A, please comment as to why.  This helps all involved, as well as others who may access this item in the future.  PLEASE DO NOT AWARD POINTS TO ME.

To view your open questions, please click the following link(s) and keep them all current with updates.

To view your locked questions, please click the following link(s) and evaluate the proposed answer.

*****  E X P E R T S    P L E A S E  ******  Leave your closing recommendations.
If you are interested in the cleanup effort, please click this link 
POINTS FOR EXPERTS awaiting comments are listed in the link below
Moderators will finalize this question if in @7 days Asker has not responded.  This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
Thanks everyone.
Moderator @ Experts Exchange
Thank you for returning and finalizing this.
Moondancer - EE Moderator
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.