다음을 통해 공유


SqlError.Message 속성

정의

오류를 설명하는 텍스트를 가져옵니다.

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

속성 값

오류를 설명하는 텍스트입니다. SQL Server 생성된 오류에 대한 자세한 내용은 데이터베이스 엔진 이벤트 및 오류를 참조하세요.

예제

다음 예제에서는 각 SqlError 내에서 SqlErrorCollection 컬렉션입니다.

using Microsoft.Data.SqlClient;
using System.Collections.Generic;
using System.Text;

namespace Classic_WebData_SqlError.StateCS
{
    class Program
    {
        static void Main()
        {
            //DisplaySqlErrors();
        }

        public void DisplaySqlErrors(SqlException exception)
        {
            for (int i = 0; i < exception.Errors.Count; i++)
            {
                Console.WriteLine("Index #" + i + "\n" +
                    "Source: " + exception.Errors[i].Source + "\n" +
                    "Number: " + exception.Errors[i].Number.ToString() + "\n" +
                    "State: " + exception.Errors[i].State.ToString() + "\n" +
                    "Class: " + exception.Errors[i].Class.ToString() + "\n" +
                    "Server: " + exception.Errors[i].Server + "\n" +
                    "Message: " + exception.Errors[i].Message + "\n" +
                    "Procedure: " + exception.Errors[i].Procedure + "\n" +
                    "LineNumber: " + exception.Errors[i].LineNumber.ToString());
            }
            Console.ReadLine();
        }
    }
}

적용 대상