INFO: OLE DB Header File Changes for 64-Bit Platform Programming (298883)



The information in this article 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:
#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;

#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;

#endif	// _WIN64
				

REFERENCES

To obtain the MDAC 2.7 library and header files that you have to have to support 64-bit compilation from the Microsoft Platform SDK, visit the following Microsoft Web site: OLE DB applications have to use the following files:
  • The Oledb.h header file.
  • The Oledb.lib library file.

Modification Type:MajorLast Reviewed:4/6/2004
Keywords:kbinfo KB298883