System.Data.OleDb Namespace

System.Data.OleDb Namespace

OleDbCommand Object Members

The OleDbCommand class represents a query command to be made to a data source. Tables B.23 through B.26 list the constructor, properties, methods , and events for the OleDbCommand class.

Table B.23. OleDbCommand Constructor

Name

Parameters

Description

OleDbCommand

none

Initializes a new instance of the OleDbCommand class.

OleDbCommand

cmdText (String)

Initializes a new instance of the OleDbCommand class with the specified command text.

OleDbCommand

cmdText (String)

connection (OleDbConnection)

Initializes a new instance of the OleDbCommand class with the specified command text and OleDbConnection .

OleDbCommand

cmdText (String)

connectionString (String)

Transaction (OleDbTransaction)

Initializes a new instance of the OleDbCommand class with the specified command text and connection string.

Table B.24. OleDbCommand Properties

Name

Type

Description

CommandText

String

Retrieves or sets the SQL command text or the provider-specific syntax to run against the data source.

CommandTimeout

Integer

Retrieves or sets the time to wait while executing the command before terminating the attempt and generating an error.

CommandType

CommandType

Retrieves or sets how the CommandText property is interpreted.

Connection

OleDbConnection

Retrieves or sets the OleDbConnection used by this instance of the the OleDbCommand .

Container

IContainer

Returns container for this component.

DesignTimeVisible

Boolean

Retrieves or sets a value indicating whether the command object should be visible in a customized Windows Form designer control.

Parameters

OleDbParameterCollection

Retrieves the OleDbParameterCollection .

Site

ISite

Retrieves or sets the site for the component.

Transaction

OleDbTransaction

Retrieves or sets the transaction in which the OleDbCommand executes.

UpdatedRowSource

UpdateRowSource

Retrieves or sets how command results are applied to the DataRow when used by the Update method of a DBDataSet Command.

Table B.25. OleDbCommand Methods

Name

Parameters

Description

Cancel

none

Cancels the execution of a command.

CreateObjRef

requestedType (Type)

Creates an object that contains all information necessary to generate a proxy used for communicating with a remote object.

CreateParameter

none

Creates a new instance of an OleDbParameter object.

Dispose

none

Releases all resources held by the component.

Dispose

disposing (Boolean)

Releases the unmanaged resources used by the MarshalByValueComponent and optionally releases the managed resources.

Equals

obj (Object)

Determines whether the specified Object is the same instance as the current Object .

Equals

objA (Object)

objB (Object)

Determines if the specified object instances are equal.

ExecuteNonQuery

none

Executes a SQL command against the data source that does not return any rows.

ExecuteReader

none

Sends the CommandText to the Conenction and builds an OleDbReader .

ExecuteReader

behavior (CommandBehavior)

Sends the CommandText to the Connection and builds an OleDbReader using one of the CommandBehavior values.

ExecuteScalar

none

Executes the query, and returns the first column of the first row in the resultset returned by the query.

GetHashCode

none

Serves as a hash function for a particular type.

GetLifetime Service

none

Retrieves a lifetime service object that controls the lifetime policy for this instance.

GetType

none

Retrieves the Type of the Object .

Initialize LifetimeService

none

Allows object to provide its own lease and control its own lifetime.

Prepare

none

Creates a prepared version of the command on the data source.

ResetCommand Timeout

none

Resets the CommandTimeout property to the default value.

ToString

none

Returns a String representing the current object.

Table B.26. OleDbCommand Events

Name

Description

Disposed

Adds an event handler to listen to the Disposed event on a component.

OleDbConnection Object Members

The OleDbConnection class represents an open connection to a data source. Tables B.27 through B.31 list the constructor, properties, methods, shared methods, and events for the OleDbConnection class.

Table B.27. OleDbConnection Constructor

Name

Parameters

Description

OleDbConnection

none

Initializes a new instance of the OleDbConnection class.

OleDbConnection

connectionString (String)

Initializes a new instance of the OleDbConnection class with the specified connection string.

Table B.28. OleDbConnection Properties

Name

Type

Description

ConnectionString

String

Retrieves or sets the string used to open a data store.

ConnectionTimeout

Integer

Retrieves or sets the string used to open a data store.

Container

IContainer

Returns the IContainer that contains the component.

Database

String

Retrieves or sets the time to wait while establishing a connection.

DataSource

String

Retrieves or sets the name of the database to connect to.

Provider

String

Retrieves or sets the name of the provider.

ServerVersion

String

Retrieves a string containing the version of the server to which the client is connected.

Site

ISite

Retrieves or sets the site of the Component .

State

ConnectionState

Retrieves the current state of the connection.

Table B.29. OleDbConnection Methods

Name

Parameters

Description

BeginTransaction

none

Begins a database transaction.

ChangeDatabase

value (String)

Changes the current database for an open OleDbConnection .

Close

none

Closes the connection to the database.

CreateCommand

none

Creates and returns an OleDbCommand object asso ciated with the OleDbConnection .

CreateObjRef

requestedType (Type)

Creates an object that contains all information necessary to generate a proxy used for communicating with a remote object.

Dispose

none

Releases all resources held by the component.

Dispose

disposing (Boolean)

Releases the unmanaged resources used by the MarshalByValueComponent and optionally releases the managed resources.

Equals

obj (Object)

Determines whether the specified Object is the same instance as the current Object .

Equals

objA (Object)

objB (Object)

Determines if the specified object instances are equal.

GetHashCode

none

Serves as a hash function for a particular type.

GetLifetimeService

none

Retrieves a lifetime service object that controls the lifetime policy for this instance.

GetOleDbSchemaTable

schema (Guid)

Restrictions[] (Object)

Returns the schema table and associated restriction columns of the specified schema.

GetType

none

Retrieves the Type of the Object .

InitializeLifetime Service

none

Allows object to provide its own lease and control its own lifetime.

Open

none

Opens a database connection with the current property settings.

ToString

none

Returns a String object that represents the current object.

Table B.30. OleDbConnection Static (Shared) Methods

Name

Parameters

Description

ReleaseObjectPool

none

Indicates that the OleDbConnection object pooling can be cleared when the last underlying OLE DB Provider is released.

Table B.31. OleDbConnection Events

Name

Description

Disposed

Adds an event handler to listen to the Disposed event on a component.

InfoMessage

Fires when the provider sends a warning or a message.

StateChanged

Fires when the state of the connection changes.

OleDbDataReader Object Members

The OleDbDataReader class represents a way of reading a forward-only stream of data records from a data source. Tables B.32 and B.33 list the properties and methods for the OleDbDataReader class.

Table B.32. OleDbDataReader Properties

Name

Type

Description

Depth

Integer

Retrieves a value indicating the depth of nesting for the current row.

FieldCount

Integer

Indicates the number of fields within the current record. This is a read-only property.

IsClosed

Boolean

Indicates whether the data reader is closed. This is a read-only property.

Item

Object

Indicates the value for a column.

RecordsAffected

Integer

Retrieves the number of rows changed, inserted, or deleted by execution of a SQL statement.

Table B.33. OleDbDataReader Methods

Name

Parameters

Description

Close

none

Closes the data reader object.

CreateObjRef

requestedType (Type)

Creates an object that contains all information necessary to generate a proxy used for communicating with a remote object.

Equals

obj (Object)

Determines whether the specified Object is the same instance as the current Object .

Equals

objA (Object)

objB (Object)

Determines if the specified object instances are equal.

GetBoolean

ordinal (Integer)

Retrieves the value of the specified column as a Boolean.

GetByte

ordinal (Integer)

Retrieves the value of the specified column as a byte.

GetBytes

ordinal (Integer)

dataIndex (Long)

buffer[] (Byte)

bufferIndex (Integer)

length (Integer)

Retrieves the value of the specified column as a byte array.

GetChar

ordinal (Integer)

Retrieves the value of the specified column as a character.

GetChars

ordinal (Integer)

dataIndex (Long)

buffer[] (Char)

bufferIndex (Integer)

length (Integer)

Retrieves the value of the specified column as a character array.

GetData

ordinal (Integer)

Not currently supported.

GetDataTypeName

index (Integer)

Retrieves the name of the back-end data type.

GetDateTime

ordinal (Integer)

Retrieves the value of the specified column as a DateTime object.

GetDecimal

ordinal (Integer)

Retrieves the value of the specified column as a Decimal object.

GetDouble

ordinal (Integer)

Retrieves the value of the specified column as a double-precision floating-point number.

GetFieldType

index (Integer)

Retrieves the Type that is the data type of the object.

GetFloat

ordinal (Integer)

Retrieves the value of the specified column as a single-precision floating-point number.

GetGuid

ordinal (Integer)

Retrieves the value of the specified column as a globally unique identifier.

GetHashCode

none

Serves as a hash function for a particular type.

GetInt16

ordinal (Integer)

Retrieves the value of the specified column as a 16-bit signed integer.

GetInt32

ordinal (Integer)

Retrieves the value of the specified column as a 32-bit signed integer.

GetInt64

ordinal (Integer)

Retrieves the value of the specified column as a 64-bit signed integer.

GetLifetime Service

none

Retrieves a lifetime service object that controls the lifetime policy for this instance.

GetName

index (Integer)

Retrieves the name of the specified column.

GetOrdinal

name (String)

Retrieves the column ordinal given the specified column name.

GetSchemaTable

none

Returns a DataTable that describes the column metadata of the OleDbDataReader .

GetString

ordinal (Integer)

Returns the value of the specified column as a string.

GetTimeSpan

ordinal (Integer)

Retrieves the value of the specified column as a TimeSpan object.

GetType

none

Retrieves the Type of the Object .

GetValue

ordinal (Integer)

Retrieves the value of the column with the specified index.

GetValues

values[] (Object)

Retrieves all the attribute fields in the collection for the current record.

Initialize LifetimeService

none

Allows object to provide its own leaseand control its own lifetime.

IsDBNull

ordinal (Integer)

Retrieves a value indicating a non- existent value.

NextResult

none

Advances the data reader to the next result set.

Read

none

Advances the data reader to the next record.

ToString

none

Returns a String representing the current Object .

OleDbDataAdapter Object Members

The OleDbDataAdapter class represents a set of data commands and a database connection that are used to populate a data set and update the data source. Tables B.34 through B.37 list the constructor, properties, methods, and events for the OleDbDataSetCommand class.

Table B.34. OleDbDataAdapter Constructor

Name

Parameters

Description

OleDbDataAdapter

none

Initializes a new instance of the OleDbDataSetCommand class.

OleDbDataAdapter

selectCommand (OleDbCommand)

Initializes a new instance of the OleDbDataSetCommand class with the specified select command.

OleDbDataAdapter

selectCommandText (String)

selectConnection (OleDbConnection)

Initializes a new instance of the OleDbDataSetCommand class with the specified select statement and OleDbConnection object

OleDbDataAdapter

selectCommandText (String)

selectConnection String (String)

Initializes a new instance of the OleDbDataSetCommand class.

Table B.35. OleDbDataAdapter Properties

Name

Type

Description

AcceptChangesDuringFill

Boolean

Retrieves or sets a value indicating whether AcceptChanges is called on a DataRow after it is added to a DataTable .

Container

IContainer

Returns the IContainer that contains the component.

DeleteCommand

OleDbCommand

Retrieves or sets a command to delete records from the data set.

InsertCommand

OleDbCommand

Retrieves or sets a command to insert records into the data source.

MissingMappingAction

MissingMappingAction

Retrieves or sets whether unmapped source tables or columns are to be passed with their source names to be filtered.

MissingSchemaAction

MissingSchemaAction

Retrieves or sets whether missing source tables, columns, and their relationships are to be added to the data set schema or ignored or whether to raise an error.

SelectCommand

OleDbCommand

Retrieves or sets a command used to select records in the data source.

Site

ISite

Retrieves or sets the site of the Component .

TableMappings

DataTableMappings

Retrieves how a source table is to be mapped to a data set table.

UpdateCommand

OleDbCommand

Retrieves or sets a command used to update records in the data source.

Table B.36. OleDbDataAdapter Methods

Name

Parameters

Description

CreateObjRef

requestType (Type)

Creates an object that contains all information necessary to generate a proxy used for communicating with a remote object.

Dispose

none

Releases all resources held by the component.

Dispose

disposing (Boolean)

Releases the unmanaged resources used by the MarshalByValueComponent and optionally releases the managed resources.

Equals

obj (Object)

Determines whether the specified Object is the same instance as the current Object .

Equals

objA (Object)

objB (Object)

Determines whether the specified object instances are equal.

Fill

dataTable (DataTable)

Adodb (Object)

Adds or refreshes rows in a DataTable to match those in an ADO recordset or Record object using the specified DataTable and ADO objects.

Fill

dataSet (DataSet)

adodb (Object)

srcTable (String)

Adds or refreshes rows in the DataSet to match those in an ADO Recordset or Record object using the specified DataSet, ADO object, and source table name.

Fill

dataSet (DataSet)

Fills the DataSet with records from the data source.

Fill

dataTable (DataTable)

Adds or refreshes rows in a DataTable to match those in the data source using the DataTable name.

Fill

dataSet (DataSet)

srcTable (String)

Fills the DataSet with records from the source table specified.

Fill

dataTable(DataTable)

dataReader (IDataReader)

Add or refreshes rows in a DataTable to match those in the data source using the specified DataTable and IDataReader .

Fill

dataTable (DataTable)

Command (IDbCommand)

Behavior (CommandBehavior)

Adds or refreshes rows in a DataTable to match those in the data source using the DataTable name, the specified SQL SELECT statement, and CommandBehavior .

Fill

dataSet (DataSet)

startRecord (Integer)

maxRecords (Integer)

srcTable (String)

Fills the DataSet with records located between the given bounds from the specified source table.

Fill

dataSet (DataSet)

srcTable (String)

dataReader (IDataReader)

startRecord (Integer)

maxRecords (Integer)

Adds or refreshes rows in a specified range in the DataSet to match those in the data source using the DataSet , DataTable , and IDataReader names.

Fill

dataSet (DataSet)

startRecord (Integer)

maxRecords (Integer)

srcTable (String)

command (IDbCommand)

behavior (CommandBehavior)

Adds or refreshes rows in a specified range in the DataSet to match those in the data source using the DataSet and source table names, command string, and command behavior.

FillSchema

dataSet (DataSet)

schemaType (SchemaType)

Adds a DataTable named "Table" to the specified DataSet and configures the schema to match that in the data source based on the specified SchemaType .

FillSchema

dataTable (DataTable)

schemaType (SchemaType)

Adds a DataTable and configures the schema of the table based on the specified SchemaType .

FillSchema

dataSet (DataSet)

schemaType (SchemaType)

srcTable (String)

Adds a DataTable to the specified DataSet and configures the schema to match that in the data source based on the specified SchemaType and DataTable .

FillSchema

dataSet (DataSet)

schemaType (SchemaType)

srcTable (String)

Adds a DataTable to the specified DataSet and configures the Schema to match that in the data source based upon the specified SchemaType and DataTable .

GetFill Parameters

none

Returns all parameters used when performing the select command.

GetHashCode

none

Serves as a hash function for a particular type.

GetLifetimeService

none

Retrieves a lifetime service object that controls the lifetime policy for this instance.

GetType

none

Retrieves the Type of the Object .

InitializeLifetime Service

none

Allows object to provide its own lease and control its own lifetime.

ToString

none

Returns a String representing the current object.

Update

datRows[] (DataRow)

Calls the respective insert , update , or delete commands for each inserted, updated, or deleted row in the given array of DataRow objects.

Update

dataset (DataSet)

Calls the respective insert , update , or delete commands for each inserted, updated, or deleted row in the specified data set.

Update

dataTable (DataTable)

Calls the respective insert , update , or delete statements for each inserted, updated, or deleted row in the specified DataTable.

Update

dataRows[] (DataRow)

tableMapping (DataTableMapping)

Calls the respective insert , update , or delete statements for each inserted, updated, or deleted row in the specified array of DataRows.

Update

dataset (DataSet)

srcTable (String)

Calls the respective insert , update , or delete commands for each inserted, updated, or deleted row in the specified data set with the given source table name.

Table B.37. OleDbDataAdapter Events

Name

Description

Disposed

Adds an event handler to listen to the Disposed event on a component.

FillError

Occurs when an error occurs during a fill operation.

RowUpdated

Fires during Update after a command is executed against the data source.

RowUpdating

Fires during Update before a command is executed against the data source.

OleDbError Object Members

The OleDbError class collects information relevant to a warning or error returned by the data source. Tables B.38 and B.39 list the properties and methods for the OleDbError class.

Table B.38. OleDbError Properties

Name

Type

Description

Message

String

Retrieves a short description of the error.

NativeError

Integer

Retrieves the database-specific error information.

Source

String

Retrieves the name of the object that generated the error.

SQLState

String

Retrieves the five-character error code following the ANSI SQL standard for the database.

Table B.39. OleDbError Methods

Name

Parameters

Description

Equals

obj (Object)

Determines whether the specified Object is the same instance as the current Object .

Equals

objA (Object)

objB (Object)

Determines whether the specified object instances are equal.

GetHashCode

none

Serves as a hash function for a particular type.

GetType

none

Retrieves the Type of the Object .

ToString

none

Retrieves the complete text of the error message.

OleDbParameter Object Members

The OleDbParameter class represents a parameter to an OleDbCommand . Tables B.40 through B.42 list the constructor, properties, and methods for the OleDbParameter class.

Table B.40. OleDbParameter Constructor

Name

Parameters

Description

OleDbParameter

none

Initializes a new instance of the OleDbParameter class.

OleDbParameter

name (String)

Value (Object)

Initializes a new instance of the OleDbParameter class with the parameter name and an OleDbParameter object.

OleDbParameter

name (String)

dataType (OleDbType)

Initializes a new instance of the OleDbParameter class with the specified name and data type.

OleDbParameter

name (String)

dataType (OleDbDBType)

size (Integer)

Initializes a new instance of the OleDbParameter class with the specified name, data type, and size.

OleDbParameter

name (String)

dataType (OleDbDBType)

size (Integer)

srcColumn (String)

Initializes a new instance of the OleDbParameter class with the specified name, data type, size, and source column name.

OleDbParameter

name (String)

dataType (OleDbDBType)

size (Integer)

direction (ParameterDirection)

isNullable (Boolean)

precision (Byte)

scale (Byte)

srcColumn (String)

srcVersion (DataRowVersion)

value (Object)

Initializes a new instance of the OleDbParameter class with the specified name, data type, size, parameter direction, precision, parameter scale, source column name, DataRowVersion, and the value of the parameter.