System.Data.OleDb Namespace

System.Data.OleDb Namespace

Provides classes for OLE DB data access. It enables communication with OLE DB data sources such as Microsoft Access, Excel, and other OLE DB‑compatible databases.

Key Classes

OleDbConnection

Represents an open connection to an OLE DB data source.

Syntax

public sealed class OleDbConnection : DbConnection

Members

MemberTypeDescription
ConnectionStringstringGets or sets the string used to open the connection.
Open()voidOpens the database connection.
Close()voidCloses the connection.
BeginTransaction()OleDbTransactionStarts a database transaction.
CreateCommand()OleDbCommandCreates a command associated with the connection.

Official documentation ↗

OleDbCommand

Represents an SQL statement or stored procedure to execute against a data source.

Syntax

public sealed class OleDbCommand : DbCommand

Members

MemberTypeDescription
CommandTextstringThe SQL query or stored procedure name.
ExecuteReader()OleDbDataReaderExecutes the command and returns a data reader.
ExecuteNonQuery()intExecutes command that does not return rows.
ParametersOleDbParameterCollectionCollection of parameters.

Official documentation ↗

OleDbDataAdapter

Fills a DataSet and updates the OLE DB data source.

Syntax

public sealed class OleDbDataAdapter : DbDataAdapter

Members

MemberTypeDescription
Fill(DataSet)intPopulates a DataSet with the result set.
Update(DataSet)intSaves changes from the DataSet back to the data source.
SelectCommandOleDbCommandThe command used to select data.

Official documentation ↗

OleDbParameter

Represents a parameter to an OleDbCommand.

Syntax

public sealed class OleDbParameter : DbParameter

Members

MemberTypeDescription
ParameterNamestringName of the parameter.
ValueobjectValue of the parameter.
DbTypeDbTypeData type of the parameter.

Official documentation ↗

OleDbDataReader

Provides a fast, forward-only way to read data from a data source.

Syntax

public sealed class OleDbDataReader : DbDataReader

Members

MemberTypeDescription
Read()boolAdvances to the next record.
GetString(int)stringGets a string value.
GetInt32(int)intGets a 32‑bit integer.

Official documentation ↗

OleDbTransaction

Represents a transaction to be performed at a data source.

Syntax

public sealed class OleDbTransaction : DbTransaction

Members

MemberTypeDescription
Commit()voidCommits the transaction.
Rollback()voidRolls back the transaction.

Official documentation ↗

OleDbException

Exception thrown when OLE DB operation fails.

Syntax

public sealed class OleDbException : DbException

Members

MemberTypeDescription
MessagestringError message.
ErrorCodeintProvider-specific error code.

Official documentation ↗

OleDbPermission

Controls access to OLE DB resources.

Syntax

public sealed class OleDbPermission : CodeAccessPermission, IUnrestrictedPermission

OleDbConnectionStringBuilder

Provides a strongly typed way to create connection strings for OLE DB.

Syntax

public sealed class OleDbConnectionStringBuilder : DbConnectionStringBuilder

Members

MemberTypeDescription
DataSourcestringGets or sets the data source.
ProviderstringGets or sets the OLE DB provider.
IntegratedSecurityboolEnables Windows authentication.

Official documentation ↗