Exemplo n.º 1
0
 // runtime will call even if private...
 private SqlException(SerializationInfo si, StreamingContext sc) : base(si, sc)
 {
     _errors = (SqlErrorCollection)si.GetValue("Errors", typeof(SqlErrorCollection));
     HResult = SqlExceptionHResult;
     foreach (SerializationEntry siEntry in si)
     {
         if (nameof(ClientConnectionId) == siEntry.Name)
         {
             _clientConnectionId = (Guid)si.GetValue(nameof(ClientConnectionId), typeof(Guid));
             break;
         }
     }
 }
Exemplo n.º 2
0
        static internal SqlException CreateException(SqlErrorCollection errorCollection, string serverVersion, SqlInternalConnectionTds internalConnection, Exception innerException = null)
        {
            Guid connectionId = (internalConnection == null) ? Guid.Empty : internalConnection._clientConnectionId;
            var  exception    = CreateException(errorCollection, serverVersion, connectionId, innerException);

            if (internalConnection != null)
            {
                if ((internalConnection.OriginalClientConnectionId != Guid.Empty) && (internalConnection.OriginalClientConnectionId != internalConnection.ClientConnectionId))
                {
                    exception.Data.Add(OriginalClientConnectionIdKey, internalConnection.OriginalClientConnectionId);
                }

                if (!string.IsNullOrEmpty(internalConnection.RoutingDestination))
                {
                    exception.Data.Add(RoutingDestinationKey, internalConnection.RoutingDestination);
                }
            }

            return(exception);
        }
Exemplo n.º 3
0
        static internal SqlException CreateException(SqlErrorCollection errorCollection, string serverVersion, Guid conId, Exception innerException = null)
        {
            Debug.Assert(null != errorCollection && errorCollection.Count > 0, "no errorCollection?");

            // concat all messages together MDAC 65533
            StringBuilder message = new StringBuilder();

            for (int i = 0; i < errorCollection.Count; i++)
            {
                if (i > 0)
                {
                    message.Append(Environment.NewLine);
                }
                message.Append(errorCollection[i].Message);
            }

            if (innerException == null && errorCollection[0].Win32ErrorCode != 0 && errorCollection[0].Win32ErrorCode != -1)
            {
                innerException = new Win32Exception(errorCollection[0].Win32ErrorCode);
            }

            SqlException exception = new SqlException(message.ToString(), errorCollection, innerException, conId);

            exception.Data.Add("HelpLink.ProdName", "Microsoft SQL Server");

            if (!ADP.IsEmpty(serverVersion))
            {
                exception.Data.Add("HelpLink.ProdVer", serverVersion);
            }
            exception.Data.Add("HelpLink.EvtSrc", "MSSQLServer");
            exception.Data.Add("HelpLink.EvtID", errorCollection[0].Number.ToString(CultureInfo.InvariantCulture));
            exception.Data.Add("HelpLink.BaseHelpUrl", "http://go.microsoft.com/fwlink");
            exception.Data.Add("HelpLink.LinkId", "20476");

            return(exception);
        }
Exemplo n.º 4
0
 private SqlException(string message, SqlErrorCollection errorCollection, Exception innerException, Guid conId) : base(message, innerException)
 {
     HResult             = SqlExceptionHResult;
     _errors             = errorCollection;
     _clientConnectionId = conId;
 }
Exemplo n.º 5
0
 static internal SqlException CreateException(SqlErrorCollection errorCollection, string serverVersion)
 {
     return(CreateException(errorCollection, serverVersion, Guid.Empty));
 }