Click here to Skip to main content
13,357,363 members (61,828 online)
Click here to Skip to main content
Add your own
alternative version


41 bookmarked
Posted 2 Dec 2001

High Performance OLE DB library : Ease of ADO, power of OLE DB

, 2 Dec 2001
Rate this:
Please Sign up or sign in to vote.
Introduction to OLE DB extended classes
<!-- Download Links -->


Most of us know that OLEDB is the latest database technology that provides fast data access on the windows platform. However, many C++ programmers tend to avoid using raw OLEDB and prefer ADO in their development process. There are two main reasons for this. First of all, OLEDB interfaces (which are COM interfaces) are extremely complex and sparsely documented. They are neither convenient nor developer-friendly. So, we are left with other choice : use ATL consumer templates for OLEDB. These template classes are very powerful and high performance. However, they lack the flexibility and rich functionality provided by ADO. Many times one has to resort to ADO for some database operations such as binding a rowset to datagrid or other controls. This is because there is no easy way to bind a OLEDB rowset to a control.

This article presents a set of classes that are extended from ATL consumer template classes for OLEDB. While these classes provide added flexibility and functionality similar to ADO, they still retain the power and performance of consumer template classes. Here, in this article, I will present only a subset of a complete libray that we have built for commercial product development. 

[1] The Connection object : CSypODLConnection

In OLEDB consumer templates, you have to deal with two classes for maintaining database connection and transaction purposes : CDataSource and CSession. This is sometimes confusing. Instead, we created a single class called CSypODLConnection that is very much like Connection object in ADO. This class combines the functionality of database connection and transaction maintenance. The use of this class is pretty simple :

CSypODLConnection m_Cnn; // Define connection 
m_Cnn.Open("CONNECTION STRING", "UID", "PWD"); // Connnect to database

You can also use transactions on this object like ADO connection

ransaction(); // Start Transaction
-- Code ---
m_Cnn.Commit(); // Commit changes

Also, like ADO connection object, we have provided Execute method for executing action queries.<!-- end the block of source code -->

m_Cnn.Execute("DELETE FROM Customer WHERE CustomerID = 5");

[1] RecordBase, Exception, and Error classes

Similarly, we have also created a recordset class called CSypODLRecordset, which wraps up CCommand and CTable comsumer template classes. Those who have worked with these consumer template classes know how tedious it is to check the HRESULT value after each method call. Not only is it time-consuming to check HRESULT value at every point, but also it is extremely difficult to get errors from IErrorInfo interface. In order to solve this problem, we created two classes : an exception class and an error-processing class. So, the code becomes very simple as shown below :

CSypODLRecordBase<CAccessor<CSalesManTableAccessor> > m_Rs; 

// Process data now
     m_Rs.Open("SalesMan", &m_Cnn, 1); // 1 indicates table
catch(CSypODLException e)  

Essentially, if you already know ADO, this library will be easy to understand and use. So, if you want to give your application a lightening speed and high performance, use these classes.

Actually, there are so many features and so many classes in the library that we can write a complete a book on it. However, due to lack of space and scope, I urge users to go through the code which is self-explanatory. Besides, the classes we have included here are only a subset of what is a complete, independent, and full-featured library. I would also advise you to study the included sample, and see how easy it is to use these classes. If you need a complete documentation, you may contact me directly.

Known drawbacks and limitations

There seems to be bugs in some OLEDB providers that may affect some of the functionality of this library. For some reason, the Update method and bookmarks fail with certain providers. Also, this library is mostly tested with JET and OleDb provider for ODBC.

If you decide to use this code

You are free to use or modify this code subject to the following restrictions:

  • You must acknowledge us somewhere in your about box or documentation, simple "Parts of code by..Sypram Technology" will be enough. If you cannot (or don't want to) mention us, contact one of us at Sypram Technology ( personally.
  • Do not remove copyright notices from the source and header files.
  • Do not publish any part of this code or article on other websites.
  • We reserve exclusive right to update this page, as well as provided source code. Please publish your modification and additions on adjacent pages. We may add your modifications and/or additions to a future update to the article and source with proper credit for your work.

If you have any other question or you need further assistance, contact me at or


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Ghanshyam Naik
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

Generaldoes not work in MSSQL2005 Pin
Member 25261797-Jan-09 7:24
memberMember 25261797-Jan-09 7:24 
GeneralRe: does not work in MSSQL2005 [modified] Pin
mpahlevan6-Mar-09 23:54
membermpahlevan6-Mar-09 23:54 
GeneralConnect to MySQL Pin
lionliu6-Aug-02 19:46
susslionliu6-Aug-02 19:46 
GeneralRe: Connect to MySQL Pin
Todd Smith6-Aug-02 19:53
memberTodd Smith6-Aug-02 19:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.180111.1 | Last Updated 3 Dec 2001
Article Copyright 2001 by Ghanshyam Naik
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid