Using ADO in C++


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.

You might also like...


About the author

Randy Charles Morin

Randy Charles Morin Canada

Randy's article are Copyright 1998-2003 Randy Charles Morin

Interested in writing for us? Find out more.


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves” - Alan Kay