I'm often asked for a HowTo tutorial on using ADO with C++. It is highly likely that I've written more ADO with C++ than anybody on the planet. I often talk about how nice it is to do database programming with ADO and C++. But this combination never made the mainstream of programming.
Programming with ADO in C++ is just as easy as with Visual Basic, you just have to explicitly release COM objects, handle exceptions and work with those nasty C++ pointers. But all in all, if you can handle the added complexity of C++, then you should be able to create much more robust applications then with junior languages like Visual Basic. The best way to use ADO in C++ is to use the smart pointers created with the #import directive in Visual C++.
#import "C:\Program files\Common Files\System\Ado\msado15.dll"
rename("EOF", "ADOEOF")
This eliminates the one of our concerns about C++, that is, explicitly releasing COM objects. The smart pointers, if used correctly, should release the objects appropriately.
Comments