SqlConnectionStringBuilder.Password 속성

정의

SQL Server 계정의 암호를 가져오거나 설정합니다.

public:
 property System::String ^ Password { System::String ^ get(); void set(System::String ^ value); };
public string Password { get; set; }
member this.Password : string with get, set
Public Property Password As String

속성 값

Password 속성의 값이거나, 제공된 값이 없으면 String.Empty입니다.

예외

암호가 null로 잘못 설정되었습니다. 다음 코드 예제를 참조하세요.

예제

다음 예제에서는 를 설정하는 Password방법을 보여줍니다.

using Microsoft.Data.SqlClient;

class Program
{
    public static void Main()
    {
        SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();

        builder["Password"] = null;
        string aa = builder.Password;
        Console.WriteLine(aa.Length);

        builder["Password"] = "??????";
        aa = builder.Password;
        Console.WriteLine(aa.Length);

        try
        {
            builder.Password = null;
        }
        catch (ArgumentNullException e)
        {
            Console.WriteLine("{0}", e);
        }
    }
}

설명

이 속성은 연결 문자열 내의 "Password" 및 "pwd" 키에 해당합니다.

이 속성을 설정하지 않는 것이 좋습니다. 높은 수준의 보안을 유지 하려면 좋습니다 사용 하 여 Integrated Security 또는 Trusted_Connection 키워드 대신 사용합니다. SqlCredential는 SQL Server 인증을 사용하는 연결에 대한 자격 증명을 지정하는 보다 안전한 방법입니다.

가 설정되지 않고 값을 검색하는 경우 Password 반환 값은 입니다 Empty. 연결 문자열의 암호를 다시 설정하려면 Item 속성에 null을 전달합니다.

암호는 128자 미만여야 합니다.

적용 대상