Oledbpp.exe Demonstrates IDBProperties::GetPropertyInfo()

ID: Q198489


The information in this article applies to:
  • Microsoft OLE DB, versions 1.5, 2.0
  • ActiveX Data Objects (ADO), versions 1.5, 2.0, 2.01, 2.1


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. Click the file name below to download the file:

Oledbpp.exe
Release Date: Jan-07-1999

For more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address
http://www.microsoft.com/downloads/search.asp
and then click How to use the Microsoft Download Center.

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 similar functionality to that of the ProviderProperties() procedure (found in AdoCore.cpp) of the ADO sample application Adovc.exe in the Microsoft Knowledge Base article Q220152 (see REFERENCES section). Basically, this sample demonstrates the use of IDBProperties::GetPropertyInfo(). Also demonstrated are IDBProperties::SetProperties() and IDBProperties::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<Object><Interface>, unless the <Object> name is included in <Interface>, (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.

// 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.
 


REFERENCES

Q220152 Sample: ADOVC1 Simple ADO/VC++ Application
MSDN: Technical Articles/Data Access/Implementing ADO with Various Development Languages

© Microsoft Corporation 1998, All Rights Reserved.
Contributions by Ken Rahmes, Microsoft Corporation

Additional query words:

Keywords : kbfile kbADO150 kbADO200 kbADO201 kbADO210 kbDatabase kbOLEDB kbOLEDB150 kbOLEDB200
Version : WINDOWS:1.5,2.0,2.01,2.1
Platform : WINDOWS
Issue type : kbinfo


Last Reviewed: December 14, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.