IDbConnection Interface

System.Data

Overview

Represents a generic connection to a database. This interface is implemented by classes that provide database connectivity for ADO.NET.

The IDbConnection interface is the base interface for all ADO.NET connection objects. It defines the core properties and methods required to establish and manage a connection to a database. Implementations of this interface provide specific connection logic for different database systems (e.g., SQL Server, Oracle, MySQL).

Key functionalities include:

Related Interfaces

Syntax

public interface IDbConnection : IDisposable

public interface IDbConnection : IDisposable
{
    // Properties
    string ConnectionString { get; set; }
    int ConnectionTimeout { get; }
    string Database { get; }
    ConnectionState State { get; }

    // Methods
    IDbTransaction BeginTransaction();
    IDbTransaction BeginTransaction(IsolationLevel isolationLevel);
    void ChangeDatabase(string databaseName);
    void Close();
    IDbCommand CreateCommand();
    void Open();
}
                

Members

Properties

Methods

Implemented Members

This interface inherits members from the System.IDisposable interface.

Requirements

Assembly

System.Data.dll

Namespace

System.Data

Platform

Windows 8.1, Windows 10, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019, .NET Framework 1.1, .NET Framework 2.0, .NET Framework 3.0, .NET Framework 3.5, .NET Framework 4.0, .NET Framework 4.5, .NET Framework 4.6, .NET Framework 4.7, .NET Framework 4.8, .NET Core 1.0, .NET Core 1.1, .NET Core 2.0, .NET Core 2.1, .NET Core 2.2, .NET Standard 1.0, .NET Standard 1.1, .NET Standard 1.2, .NET Standard 1.3, .NET Standard 1.4, .NET Standard 1.5, .NET Standard 1.6, .NET Standard 2.0, .NET Standard 2.1, .NET 5, .NET 6, .NET 7, .NET 8