Conversions Involving Strings

OLE DB Programmer's Reference

The following formats are used for conversions to and from strings. Only nontrivial formats are listed. Converting a string to a nonstring type may fail for some providers if the string contains trailing blanks.

Type indicator Format
DBTYPE_BYTES When strings are converted to and from binary data, each byte of binary data is represented as two ASCII characters. These characters are the ASCII character representation of the number in its hexadecimal form. For example, the string value "f222" is converted to 0xf2 0x22, and the value 0x01 0x01 is converted to the string "0101".
DBTYPE_CY "...cccc.cccc"
DBTYPE_BOOL "True" and "False"
DBTYPE_DATE As in Automation, this may be localized based on provider-specific settings. For example, for the "English(United States)" default setting, this would typically be the following:

"mm/dd/yy hh:mm:ss {AM|PM}"

To control how this is localized, consumers should bind as DBTYPE_DATE or DBTYPE_VARIANT and do their own conversions.

DBTYPE_DBDATE As specified by ISO:

"yyyy-mm-dd"

DBTYPE_FILETIME "yyyyy-mm-dd hh:mm:ss.fff" where fff is 0–999. Up to 3 digits may be used. The format is the same as SYSTEMTIME. Valid filetime value is 0x0000000000000000-0x7FFFFFFFFFFFFFFF, which is 01601-01-01 00:00:000-30828-09-14 02:24:05.477.
DBTYPE_DBTIME As specified by ISO:

"hh:mm:ss"

DBTYPE_DBTIMESTAMP As specified by ISO:

"yyyy-mm-dd hh:mm:ss.f..."

where "f..." is fractions of a second. (Up to nine digits may be used.)

DBTYPE_GUID As represented in the registry:

"{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}"

where x is a hexadecimal digit.

DBTYPE_STR
DBTYPE_WSTR
DBTYPE_BSTR
DBTYPE_HCHAPTER
Conversion between strings of different locale IDs (LCIDs) is not supported. Conversion between ANSI and Unicode strings of the same LCID are required.

In converting a Unicode string to ANSI, information may be lost because the Unicode range is greater. Lost characters are represented in the ANSI string by a special character, and the conversion is considered to be a truncation.

When mixing character sets, conversion to Unicode is the preferred solution. If conversion to ANSI is needed to use ANSI strings with the user interface and the LCID of the user interface is different from the LCID of some columns, the consumer is responsible for the conversion. The LCID of a column is returned in the DBCOLUMN_COLLATING_SEQUENCE column returned by IColumnsRowset::GetColumnsRowset.

When DBTYPE_HCHAPTER is converted to DBTYPE_WSTR, the characters are the ASCII representation of the number in its hexadecimal form. For example, 0xf2220101 is converted to the string "f2220101".

When DBTYPE_WSTR is converted to DBTYPE_HCHAPTER, each byte of binary data represents two ASCII characters. For example, "f2220101" becomes 0xf2220101, and "f222" becomes 0xf222. The conversion will fail if the value does not appear to represent a valid HCHAPTER or if truncation would occur.

1998-2001 Microsoft Corporation. All rights reserved.



Microsoft Ole Db 2.0 Programmer's Reference and Data Access SDK
Microsoft OLE DB 2.0 Programmers Reference and Data Access SDK (Microsoft Professional Editions)
ISBN: 0735605904
EAN: 2147483647
Year: 1998
Pages: 1083

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net