OLE DB 数据类型映射 (ADO.NET)

更新:November 2007

下表显示了针对适用于 ADO 和 OLE DB 的 .NET Framework 数据提供程序 (System.Data.OleDb) 中的数据类型推断出的 .NET Framework 类型。另外,还列出了 OleDbDataReader 的类型化访问器方法。

ADO 类型

OLE DB 类型

.NET Framework 类型

.NET Framework 类型化访问器

adBigInt

DBTYPE_I8

Int64

GetInt64()

adBinary

DBTYPE_BYTES

Byte[]

GetBytes()

adBoolean

DBTYPE_BOOL

Boolean

GetBoolean()

adBSTR

DBTYPE_BSTR

String

GetString()

adChapter

DBTYPE_HCHAPTER

通过 DataReader 支持。请参见使用 DataReader 检索数据 (ADO.NET)

GetValue()

adChar

DBTYPE_STR

String

GetString()

adCurrency

DBTYPE_CY

Decimal

GetDecimal()

adDate

DBTYPE_DATE

DateTime

GetDateTime()

adDBDate

DBTYPE_DBDATE

DateTime

GetDateTime()

adDBTime

DBTYPE_DBTIME

DateTime

GetDateTime()

adDBTimeStamp

DBTYPE_DBTIMESTAMP

DateTime

GetDateTime()

adDecimal

DBTYPE_DECIMAL

Decimal

GetDecimal()

adDouble

DBTYPE_R8

Double

GetDouble()

adError

DBTYPE_ERROR

ExternalException

GetValue()

adFileTime

DBTYPE_FILETIME

DateTime

GetDateTime()

adGUID

DBTYPE_GUID

Guid

GetGuid()

adIDispatch

DBTYPE_IDISPATCH *

Object

GetValue()

adInteger

DBTYPE_I4

Int32

GetInt32()

adIUnknown

DBTYPE_IUNKNOWN *

Object

GetValue()

adNumeric

DBTYPE_NUMERIC

Decimal

GetDecimal()

adPropVariant

DBTYPE_PROPVARIANT

Object

GetValue()

adSingle

DBTYPE_R4

Single

GetFloat()

adSmallInt

DBTYPE_I2

Int16

GetInt16()

adTinyInt

DBTYPE_I1

Byte

GetByte()

adUnsignedBigInt

DBTYPE_UI8

UInt64

GetValue()

adUnsignedInt

DBTYPE_UI4

UInt32

GetValue()

adUnsignedSmallInt

DBTYPE_UI2

UInt16

GetValue()

adUnsignedTinyInt

DBTYPE_UI1

Byte

GetByte()

adVariant

DBTYPE_VARIANT

Object

GetValue()

adWChar

DBTYPE_WSTR

String

GetString()

adUserDefined

DBTYPE_UDT

不受支持

   

adVarNumeric

DBTYPE_VARNUMERIC

不受支持

   

* 对于 OLE DB 类型 DBTYPE_IUNKNOWN 和 DBTYPE_IDISPATCH,对象引用是指针的封送表示形式。

请参见

其他资源

在 ADO.NET 中检索和修改数据