Прочитај на енглеском Уреди

Делите путем


SqlConnection.Credential Property

Definition

Gets or sets the SqlCredential object for this connection.

C#
public System.Data.SqlClient.SqlCredential Credential { get; set; }
C#
[System.ComponentModel.Browsable(false)]
public System.Data.SqlClient.SqlCredential Credential { get; set; }

Property Value

The SqlCredential object for this connection.

Attributes

Remarks

Persist Security Info = true is required to get the value of the SqlCredential object with Credential.

The default value of Credential is null.

An InvalidOperationException exception will be raised:

  • If Credential is set on an open connection.

  • If Credential is set when Context Connection=true.

  • If Credential is set when Integrated Security = true.

  • If Credential is set when the connection string uses Password.

  • If Credential is set when the connection string uses UserID.

Applies to

Производ Верзије
.NET 6 (package-provided), 7 (package-provided), 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

See also