Microsoft KB Archive/198489

= Oledbpp.exe Demonstrates IDBProperties::GetPropertyInfo =

Article ID: 198489

Article Last Modified on 3/14/2005

-

APPLIES TO


 * Microsoft OLE DB 1.5
 * Microsoft OLE DB 2.0
 * Microsoft OLE DB 2.1
 * Microsoft OLE DB 2.5
 * Microsoft OLE DB 2.6
 * Microsoft ActiveX Data Objects 1.5
 * Microsoft ActiveX Data Objects 2.0
 * Microsoft ActiveX Data Objects 2.01
 * Microsoft ActiveX Data Objects 2.1
 * Microsoft ActiveX Data Objects 2.5
 * Microsoft ActiveX Data Objects 2.6

-



This article was previously published under Q198489



SUMMARY
Oledbpp.exe is a sample that uses OLE DB, with Visual C++ 6.x, to demonstrate the use of the IDBProperties::GetPropertyInfo method.



MORE INFORMATION
The following file is available for download from the Microsoft Download Center:

Oledbpp.exe

Release Date: Jan-07-1999

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

Using the Sample File
The contents of Oledbpp.exe include the following:    FileName      Description -

Adodemo.mdb   The sample Microsoft Access database Oledbpp.cpp   The main module for the OLEDBPP Application Oledbpp.h     Header for the OLEDBPP Application Oledbppdlg.cpp The module containing the OLE DB code Oledbppdlg.h  Header for the COLEDBPPDlg class Pperror.cpp   Edited version of error.cpP from RowsetViewer sample Pperror.h     Header for the Pperror.cpp file Stdafx.cpp    Build generated Stdafx.h      Build generated

What OLEDBPP Demonstrates
OLEDBPP is a sample that demonstrates the use of IDBProperties::GetPropertyInfo. Also demonstrated are IDBProperties::SetProperties and IDBInitialize::Initialize. Extensive in-line comments describe the detailed syntax of the OLE DB methods and structures.

Conventions
In the sample, pointers to OLE DB interfaces are named following the convention: p, unless the  name is included in , (for example, pICommandWithParameters or pIRowset). For example, pDataSourceIDBInitialize or pSessionIDBCreateCommand.

Calling IDBProperties::GetPropertyInfo
As an example of the kind of in-line tutorial provided, the following code fragment demonstrates the use of the IDBProperties::GetPropertyInfo method.

NOTE: This sample uses Microsoft Jet, which is not included in MDAC 2.6. To use this sample you must have Microsoft Jet OLEDB Provider installed on the computer. // Dump connection properties

DBPROPSET*      rgPropSets = NULL; ULONG           cPropSets = 0;

ULONG           cPropertyIDSets = 0L; ULONG           cPropertyInfoSets; DBPROPINFOSET*  rgPropertyInfoSets; // Returned by provider OLECHAR*        pDescBuffer;  // Returned by provider

///////////////////////////////////////////////////////////////////// // typedef struct  tagDBPROPINFOSET //   { //    /* [size_is] */ PDBPROPINFO rgPropertyInfos; //   ULONG cPropertyInfos; //   GUID guidPropertySet; //   }   DBPROPINFOSET; // // The DBPROPINFOSET structure's guidPropertySet, if set, will be // one of the following: //    DBPROPSET_DATASOURCEALL //    DBPROPSET_DATASOURCEINFOALL //    DBPROPSET_DBINITALL //    DBPROPSET_ROWSETALL //    DBPROPSET_SESSIONALL // // typedef struct  tagDBPROPINFO //   { //    LPOLESTR pwszDescription; // A text description of the property //   DBPROPID dwPropertyID; // The ID of the property

//   DBPROPFLAGS dwFlags;   // A bitmask that describes the property //   VARTYPE vtType;        // The type indicator of the property //   VARIANT vValues; // Alist of the supported values for the //                    // property* //   }   DBPROPINFO; // //   * Normally this list is returned only if the property can be //      set and either: //     (a) The property type is an integer and the possible values of //          the property are an enumerated type. //     (b) The property type is an integer whose bits are to be read //         as a bitmask and all supported bits are set. //     (c) The property type is a string and the possible values form //         a small, well-defined set. The definition of a small, well- //         defined set is provider-specific. (If this list is //         returned the vt element in vValues is VT_ARRAY combined with //          the type indicator returned in vtType.  If this list is not //          returned,the vt element is VT_EMPTY.  The consumer must free //          any memory pointed to by elements of vValues by calling the //          COM function VariantClear. //////////////////////////////////////////////////////////////////////

hr = pDataSourceIDBProperties->GetPropertyInfo(cPropertyIDSets,       NULL, // Since above is 0L, this is ignored by provider        &cPropertyInfoSets, // # DBPROPINFOSET structures returned        &rgPropertyInfoSets, // The DBPROPINFOSET structures themselves        &pDescBuffer); // Memory location with pointer to string data // Each individual string value is null-terminated.

