Microsoft KB Archive/298883

= INFO: OLE DB Header File Changes for 64-Bit Platform Programming =

Article ID: 298883

Article Last Modified on 4/6/2004

-

APPLIES TO


 * Microsoft Data Access Components 2.7

-



This article was previously published under Q298883



SUMMARY
The OLE DB database components that are included with the Microsoft Data Access Components (MDAC) 2.7 software development kit (SDK) contain some changes from earlier versions of OLE DB to allow programmers to code to the new 64-bit platforms. This article summarizes those changes.



MORE INFORMATION
OLE DB has added several new typedefs to the headers. These new typedefs make it easier to use the same source to compile for both 32-bit and 64-bit platforms based on the WIN32 and _WIN64 defines. The new typedefs are shown in the following code from the oledb.h header file. When you port existing OLE DB code to work on a 64-bit platform, the code must be checked to make sure that the correct typedefs are used. For example, when you have the following code: int cCol = 32; hr = pIColumnsInfo->GetColumnInfo(&cCol, &pColumnInfo, &pStringsBuffer); Change the type of cCol so that it uses the DBORDINAL datatype. The call becomes the following: DBORDINAL cCol = 32; hr = pIColumnsInfo->GetColumnInfo(&cCol, &pColumnInfo, &pStringsBuffer); This code now compiles and runs on 32-bit and 64-bit platforms. Details of the relevant new types in the OLE DB headers are shown as follows:
 * 1) ifdef _WIN64

// Length of a non-character object, size. typedef ULONGLONG          DBLENGTH;

// Offset in a rowset. typedef LONGLONG           DBROWOFFSET;

// Number of rows. typedef LONGLONG           DBROWCOUNT;

typedef ULONGLONG          DBCOUNTITEM;

// Ordinal (column number, and so on.) typedef ULONGLONG          DBORDINAL;

typedef LONGLONG           DB_LORDINAL;

// Bookmarks. typedef ULONGLONG          DBBKMARK; // Offset in the buffer.

typedef ULONGLONG          DBBYTEOFFSET; // Reference count of each row/accessor handle.

typedef ULONG              DBREFCOUNT;

// Parameters. typedef ULONGLONG          DB_UPARAMS;

typedef LONGLONG           DB_LPARAMS;

// Hash values corresponding to the elements (bookmarks). typedef DWORDLONG          DBHASHVALUE;

// For reserve. typedef DWORDLONG          DB_DWRESERVE;

typedef LONGLONG           DB_LRESERVE;

typedef ULONGLONG          DB_URESERVE;


 * 1) else //_WIN64

// Length of a non-character object, size. typedef ULONG DBLENGTH;

// Offset in a rowset. typedef LONG DBROWOFFSET;

// Number of rows. typedef LONG DBROWCOUNT;

typedef ULONG DBCOUNTITEM;

// Ordinal (column number, and so on.) typedef ULONG DBORDINAL;

typedef LONG DB_LORDINAL;

// Bookmarks. typedef ULONG DBBKMARK;

// Offset in the buffer. typedef ULONG DBBYTEOFFSET;

// Reference count of each row handle. typedef ULONG DBREFCOUNT;

// Parameters. typedef ULONG DB_UPARAMS;

typedef LONG DB_LPARAMS;

// Hash values corresponding to the elements (bookmarks). typedef DWORD DBHASHVALUE;

// For reserve. typedef DWORD DB_DWRESERVE;

typedef LONG DB_LRESERVE;

typedef ULONG DB_URESERVE;


 * 1) endif // _WIN64

