We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 67,702 times

Contents

Related Categories

Using ADO in C++ - Introduction

randy

Introduction

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.

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

Comments

  • Posted by souvik on 29 Aug 2005


    yes , it can be used, but in this case , compiler will treat it as auto variable. Compiler will only generate warning.

  • register variable

    Posted by carthyc on 15 Jul 2005

    hai,

    can we use register variable for storing address

  • I now interested in this,hope any news about this:

    Posted by angus on 10 Jul 2005

    :o :(

  • C language and ADO usage

    Posted by rassul on 02 May 2005

    Hi,

    Does anyone know how to use C language (not C++) with ADO and/or ODBC againt SQL Server. Any sample or a link to a sample is very much appreciated. Thanks in advance.

    Rass

  • Adding a Record

    Posted by vohalloran on 24 Apr 2005

    Now show me how to add a new record to the database. After many hours of working on this, I finally got the program to retrieve the records from the Access database, but I have no idea how to add a ...