共用方式為


Data Types in OLE DB (OLE DB)

This section introduces OLE DB data type indicators. Providers use these type indicators to tell consumers what data types they support. Consumers use them when creating tables and when getting and setting data. Example mappings from native data types to OLE DB data type indicators are given for an ANSI SQL provider, a Microsoft? Access provider, and a Microsoft SQL Server provider. The treatment of string values and provider support for data type conversions are also discussed.

For more information on

Go to

Consumers and providers

Conceptual Programming Models in OLE DB

Using type indicators in providers

Using Type Indicators in Providers

Type indicators in an ANSI SQL Provider

Type Indicators in an ANSI SQL Provider

Type indicators in a Microsoft Access provider

Type Indicators in a Microsoft Access Provider

Type indicators in a Microsoft SQL Server provider

Type Indicators in a Microsoft SQL Server Provider

Using type indicators in consumers

Using Type Indicators in Consumers

Using type indicators when creating tables in consumers

Using Type Indicators When Creating Tables

Using type indicators when getting and setting data in consumers

Using Type Indicators When Getting and Setting Data

Determining the type of data from a string

String Data

Fixed-length and variable-length data

Fixed-Length and Variable-Length Data Types

Provider support for data type conversions

Data Type Conversion

OLE DB uses standard OLE and Microsoft Windows? data types. To describe a data type, a type indicator is used. This is a variable of the enumerated type DBTYPE that is passed as metadata. Although it is easy to confuse the two, type indicators are not data types. For example, DBTYPE_GUID is an integer with a value of 72, not a GUID. It is used to indicate that a piece of memory contains a GUID. For more information on how data types map to type indicators as well as a complete list of type indicators, see Type Indicators in Appendix A: Data Types.

Places where type indicators are used include the following:

  • Metadata. Type indicators are used to specify the data type of a column or parameter.

  • DBBINDING structures. The wType element of the DBBINDING structure describes the type of the bound data value. When getting data, this is the type to which the provider converts the data before returning it to the consumer. When setting data, this is the type from which the provider converts the data after retrieving it from the consumer.

  • VARIANT structures. The vt element, a short integer, of the VARIANT structure indicates the type of the data that is stored in the structure. The remainder of the structure is 14 bytes, which are structured according to the vt tag. The DBTYPE enumerated type is a superset of the VARENUM enumerated type, so some DBTYPE values cannot be used in VARIANT structures.