OdbcException.Source 속성

정의

오류를 생성한 ODBC 드라이버의 이름을 가져옵니다.

public:
 virtual property System::String ^ Source { System::String ^ get(); };
public override string Source { get; }
member this.Source : string
Public Overrides ReadOnly Property Source As String

속성 값

오류를 생성한 ODBC 드라이버의 이름입니다.

예제

다음 예에서는 컬렉션 내에서 첫 번째 MessageOdbcError 의 , SourceNativeError 속성을 표시합니다OdbcErrorCollection.

public void ShowOdbcException()
{
   string mySelectQuery = "SELECT column1 FROM table1";
   OdbcConnection myConnection =
      new OdbcConnection("DRIVER={SQL Server};SERVER=MyServer;Trusted_connection=yes;DATABASE=northwind;");
   OdbcCommand myCommand = new OdbcCommand(mySelectQuery,myConnection);
   try
   {
      myCommand.Connection.Open();
   }
   catch (OdbcException e)
   {
     string errorMessage = "Message: " + e.Message + "\n" +
                           "Source: " + e.Source;

     System.Diagnostics.EventLog log = new System.Diagnostics.EventLog();
     log.Source = "My Application";
     log.WriteEntry(errorMessage);
     Console.WriteLine("An exception occurred. Please contact your system administrator.");
   }
}
Public Sub ShowOdbcException()
    Dim mySelectQuery As String = "SELECT column1 FROM table1"
    Dim myConnection As New OdbcConnection _
       ("DRIVER={SQL Server};SERVER=MyServer;Trusted_connection=yes;DATABASE=northwind;")
    Dim myCommand As New OdbcCommand(mySelectQuery, myConnection)
    Try
        myCommand.Connection.Open()
    Catch e As OdbcException
        Dim errorMessage As String = "Message: " & e.Message & vbCrLf & _
                                     "Source: " & e.Source

       Dim log As New System.Diagnostics.EventLog()
       log.Source = "My Application"
       log.WriteEntry(errorMessage)
       Console.WriteLine("An exception occurred. Please contact your system administrator.")
    End Try
End Sub

설명

이 대 한 래퍼인 합니다 Source 첫 번째 속성 OdbcErrorErrors 컬렉션.

적용 대상

추가 정보