[ Team LiB ] Previous Section Next Section

A.2 The OLE DB Provider

The OLE DB provider interface provides access to a database through an OLE DB provider installed on your computer. Most OLE DB providers are supported, but those that use OLE DB Version 2.5 interfaces aren't supported. Some unsupported OLE DB interfaces include:

  • OLE DB provider for ODBC (MSDASQL)

  • OLE DB provider for Exchange (ExOLEDB)

  • OLE DB for Internet Publishing (MSDAIPP)

Table A-3 lists some commonly used OLE DB drivers.

Table A-3. Commonly used OLE DB drivers

Name

Description

SQLOLEDB

OLE DB provider for SQL Server

MSDAORA

OLE DB provider for Oracle 7.3 and Oracle 8.

Microsoft.Jet.OLEDB.4.0

OLE DB provider for Access (and other Jet data sources)

All OLE DB types are contained in the System.Data.OleDb namespace (see Table A-4). For low-level information about OLE DB providers, you can refer to the OLE DB programmer's reference on MSDN at http://msdn.microsoft.com/library/en-us/oledb/htm/oledb_providers_overview.asp.

Table A-4. OLE DB .NET provider classes

Interface

Implementing class

IDbConnection
OleDbConnection
IDbCommand
OleDbCommand

IDataParameter, IDbDataParameter

OleDbParameter

IDataReader, IDataRecord

OleDbDataReader

IDataAdapter, IDbDataAdapter

OleDbDataAdapter
IDbTransaction
OleDbTransaction

The OLE DB managed provider doesn't include any structures for OLE DB types. However, the OleDbDataReader does include additional methods that allow you to specify the data type when retrieving a column value. Table A-5 shows the mapping between OLE DB types and .NET framework types (although it doesn't include types used exclusively for stored procedure parameters).

Table A-5. OLE DB type mappings

OLE DB data type

Mapped .NET type

Name in OleDBType enumeration

DBTYPE_I8
Int64
BigInt
DBTYPE_BYTES 
Byte[]
Binary
DBTYPE_BOOL
Boolean
Boolean
DBTYPE_BSTR
String
BSTR
DBTYPE_STR
String
Char
DBTYPE_CY
Decimal
Currency
DBTYPE_DATE
DateTime
Date
DBTYPE_DBDATE
DateTime
DBDate
DBTYPE_DBTIME
TimeSpan
DBTime
DBTYPE_DBTIMESTAMP
DateTime
DBTimeStamp
DBTYPE_DECIMAL
Decimal
Decimal
DBTYPE_R8
Double
Double
DBTYPE_EMPTY

Not applicable

Empty
DBTYPE_ERROR
Exception
Error
DBTYPE_FILETIME
DateTime
Filetime
DBTYPE_GUID
Guid
Guid
DBTYPE_IDISPATCH

Not supported

IDispatch
DBTYPE_I4
Int32
Integer
DBTYPE_UNKNOWN

Not supported

IUnknown
DBTYPE_NUMERIC
Decimal
Numeric
DBTYPE_PROPVARIANT
Object
PropVarian
DBTYPE_R4
Single
Single
DBTYPE_I2
Int16
SmallInt
DBTYPE_I1
SByte
TinyInt
DBTYPE_UI8
UInt64
UnsignedBitInt
DBTYPE_UI4
UInt32
UnsignedInt
DBTYPE_UI2
UInt16
UnsignedSmallInt
DBTYPE_UI1
Byte
UnsignedTinyInt
DBTYPE_VARIANT
Object
Variant
DBTYPE_WSTR
String
WChar

    [ Team LiB ] Previous Section Next Section