Click here to Skip to main content
Full site     10M members (41K online)    

A set of MFC wrapper classes for ADO - Version 2.20J

Introduction

This is a small update I made to the excellent set of ADO classes by Carlos Antollini. Though this might be a little less common than .NET classes, MFC is still very much in use and I hope the changes would be useful to someone.

Background

Dated back to 2005, the original classes did not account for 64 bit data and compilers. I have taken the liberty to add support for 64 bit data such as MS-SQL BIGINT. I also have support for 64 bit binary data to 64 int conversion useful in situations where we must read MS-SQL ROWVERSION and similar type fields.

I have also added a handful of utility functions to make common tasks part of the classes. I did however kept the original code in place for the most part and insured to keep backward compatibility.

Of course, all of this is meant to be compiled as a 32 bit application. I might add more for 64 bit applications later, if necessary.

You might also have to get a new TLB for some operating system. It is included in this article and from Microsoft. (msado60_Backcompat_i386.tlb)

Using the code

In this section, I will not repeat what Carlos described in detail in his original post but concentrate on my changes.

Tweaking the header for the host operating system

Depending on the bit size of the host operating system, a different version of ADO is used. Make sure to define this value before including the header if needed:

#define _USE_WINX86_FOLDER_    //Use this when compiling on 64 bit PC
#include <ado2.h>              //ADO wrapper class  

New stuff

First, support 64 bit data:

The GetFieldValue functions returns a value that contains the value of a field.

BOOL GetFieldValue(LPCTSTR lpFieldName, INT64& lValue);
BOOL GetFieldValue(int nIndex, INT64& lValue);
BOOL GetFieldValue(LPCTSTR lpFieldName, UINT64& ulValue);
BOOL GetFieldValue(int nIndex, UINT64& ulValue); 

The SetFieldValue functions sets the value of a field.

BOOL SetFieldValue(int nIndex, INT64 lValue);
BOOL SetFieldValue(LPCTSTR lpFieldName, INT64 lValue);
BOOL SetFieldValue(int nIndex, UINT64 lValue);
BOOL SetFieldValue(LPCTSTR lpFieldName, UINT64 lValue); 

New utility functions

Here are my new utility functions that wraps commonly used tasks.

The CADODatabase class has a set of functions that corresponds to the _ConnectionPtr. To this class, I have added these:

The CADORecordset class has a set of functions that corresponds to the _RecordsetPtr. To this class, I have added these:

The new CADOTool class has a set of static utility functions that wraps common tasks:

History

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search 
Per page   
Questiongreat job.if there is a demo application will be much better
ASERERTA@#@s
10 May '13 - 18:11 
GeneralMy vote of 5
kevinwzy
8 May '13 - 6:11 
GeneralRe: My vote of 5
Joffrey Brouillet
8 May '13 - 7:08 

Last Updated 8 May 2013 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2013