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 |
|
Using type indicators in providers |
|
Type indicators in an ANSI SQL Provider |
|
Type indicators in a Microsoft Access provider |
|
Type indicators in a Microsoft SQL Server provider |
|
Using type indicators in consumers |
|
Using type indicators when creating tables in consumers |
|
Using type indicators when getting and setting data in consumers |
|
Determining the type of data from a string |
|
Fixed-length and variable-length data |
|
Provider support for data type conversions |
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.