<PackageReference Include="System.Data.SqlClient" Version="4.7.0" />

SqlConnection

public sealed class SqlConnection : DbConnection, ICloneable
Represents a connection to a SQL Server database. This class cannot be inherited.
public string AccessToken { get; set; }

Gets or sets the access token for the connection.

public Guid ClientConnectionId { get; }

The connection ID of the most recent connection attempt, regardless of whether the attempt succeeded or failed.

public SqlCredential Credential { get; set; }

Gets or sets the SqlCredential object for this connection.

public bool FireInfoMessageEventOnUserErrors { get; set; }

Gets or sets the FireInfoMessageEventOnUserErrors property.

public int PacketSize { get; }

Gets the size (in bytes) of network packets used to communicate with an instance of SQL Server.

public bool StatisticsEnabled { get; set; }

When set to true, enables statistics gathering for the current connection.

public string WorkstationId { get; }

Gets a string that identifies the database client.

Occurs when SQL Server returns a warning or informational message.

public SqlConnection()

Initializes a new instance of the SqlConnection class.

public SqlConnection(string connectionString)

Initializes a new instance of the SqlConnection class when given a string that contains the connection string.

public SqlConnection(string connectionString, SqlCredential credential)

Initializes a new instance of the SqlConnection class given a connection string, that does not use Integrated Security = true and a SqlCredential object that contains the user ID and password.

public static void ChangePassword(string connectionString, SqlCredential credential, SecureString newPassword)

Changes the SQL Server password for the user indicated in the SqlCredential object.

public static void ChangePassword(string connectionString, string newPassword)

Changes the SQL Server password for the user indicated in the connection string to the supplied new password.

public static void ClearAllPools()

Empties the connection pool.

public static void ClearPool(SqlConnection connection)

Empties the connection pool associated with the specified connection.

Starts a database transaction.

Starts a database transaction with the specified isolation level.

public SqlTransaction BeginTransaction(IsolationLevel iso, string transactionName)

Starts a database transaction with the specified isolation level and transaction name.

public SqlTransaction BeginTransaction(string transactionName)

Starts a database transaction with the specified transaction name.

Creates and returns a SqlCommand object associated with the SqlConnection.

public void ResetStatistics()

If statistics gathering is enabled, all values are reset to zero.

Returns a name value pair collection of statistics at the point in time the method is called.