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 a connection to a data source.
- OleDbCommand – Executes commands against a data source.
- OleDbDataReader – Provides forward‑only, read‑only access to data.
- OleDbDataAdapter – Fills DataSet and updates the data source.
- OleDbParameter – Represents a parameter to an OleDbCommand.
- OleDbTransaction – Represents a database transaction.
OleDbConnection
Represents an open connection to an OLE DB data source.
Syntax
public sealed class OleDbConnection : DbConnection
Members
Member | Type | Description |
---|---|---|
ConnectionString | string | Gets or sets the string used to open the connection. |
Open() | void | Opens the database connection. |
Close() | void | Closes the connection. |
BeginTransaction() | OleDbTransaction | Starts a database transaction. |
CreateCommand() | OleDbCommand | Creates a command associated with the connection. |
OleDbCommand
Represents an SQL statement or stored procedure to execute against a data source.
Syntax
public sealed class OleDbCommand : DbCommand
Members
Member | Type | Description |
---|---|---|
CommandText | string | The SQL query or stored procedure name. |
ExecuteReader() | OleDbDataReader | Executes the command and returns a data reader. |
ExecuteNonQuery() | int | Executes command that does not return rows. |
Parameters | OleDbParameterCollection | Collection of parameters. |
OleDbDataAdapter
Fills a DataSet and updates the OLE DB data source.
Syntax
public sealed class OleDbDataAdapter : DbDataAdapter
Members
Member | Type | Description |
---|---|---|
Fill(DataSet) | int | Populates a DataSet with the result set. |
Update(DataSet) | int | Saves changes from the DataSet back to the data source. |
SelectCommand | OleDbCommand | The command used to select data. |
OleDbParameter
Represents a parameter to an OleDbCommand.
Syntax
public sealed class OleDbParameter : DbParameter
Members
Member | Type | Description |
---|---|---|
ParameterName | string | Name of the parameter. |
Value | object | Value of the parameter. |
DbType | DbType | Data type of the parameter. |
OleDbDataReader
Provides a fast, forward-only way to read data from a data source.
Syntax
public sealed class OleDbDataReader : DbDataReader
Members
Member | Type | Description |
---|---|---|
Read() | bool | Advances to the next record. |
GetString(int) | string | Gets a string value. |
GetInt32(int) | int | Gets a 32‑bit integer. |
OleDbTransaction
Represents a transaction to be performed at a data source.
Syntax
public sealed class OleDbTransaction : DbTransaction
Members
Member | Type | Description |
---|---|---|
Commit() | void | Commits the transaction. |
Rollback() | void | Rolls back the transaction. |
OleDbException
Exception thrown when OLE DB operation fails.
Syntax
public sealed class OleDbException : DbException
Members
Member | Type | Description |
---|---|---|
Message | string | Error message. |
ErrorCode | int | Provider-specific error code. |
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
Member | Type | Description |
---|---|---|
DataSource | string | Gets or sets the data source. |
Provider | string | Gets or sets the OLE DB provider. |
IntegratedSecurity | bool | Enables Windows authentication. |