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 System;
using System.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);
      }
   }
}
Imports System.Data.SqlClient
Public Class Program
   Public Shared Sub Main()

      Dim builder As New SqlConnectionStringBuilder()

      builder("Password") = Nothing
      Dim aa As String = builder.Password
      Console.WriteLine(aa.Length)

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

      Try
         builder.Password = Nothing
      Catch e As ArgumentNullException
         Console.WriteLine("{0}", e)
      End Try
   End Sub
End Class

설명

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

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

적용 대상

추가 정보