internal static OleDbException CreateException(System.Data.Common.UnsafeNativeMethods.IErrorInfo errorInfo, OleDbHResult errorCode, Exception inner)
 {
     OleDbErrorCollection errors = new OleDbErrorCollection(errorInfo);
     string pBstrDescription = null;
     string pBstrSource = null;
     OleDbHResult description = OleDbHResult.S_OK;
     if (errorInfo != null)
     {
         description = errorInfo.GetDescription(out pBstrDescription);
         Bid.Trace("<oledb.IErrorInfo.GetDescription|API|OS|RET> %08X{HRESULT}, Description='%ls'\n", description, pBstrDescription);
         description = errorInfo.GetSource(out pBstrSource);
         Bid.Trace("<oledb.IErrorInfo.GetSource|API|OS|RET> %08X{HRESULT}, Source='%ls'\n", description, pBstrSource);
     }
     int count = errors.Count;
     if (0 < errors.Count)
     {
         StringBuilder builder = new StringBuilder();
         if ((pBstrDescription != null) && (pBstrDescription != errors[0].Message))
         {
             builder.Append(pBstrDescription.TrimEnd(ODB.ErrorTrimCharacters));
             if (1 < count)
             {
                 builder.Append(Environment.NewLine);
             }
         }
         for (int i = 0; i < count; i++)
         {
             if (0 < i)
             {
                 builder.Append(Environment.NewLine);
             }
             builder.Append(errors[i].Message.TrimEnd(ODB.ErrorTrimCharacters));
         }
         pBstrDescription = builder.ToString();
     }
     if (ADP.IsEmpty(pBstrDescription))
     {
         pBstrDescription = ODB.NoErrorMessage(errorCode);
     }
     return new OleDbException(pBstrDescription, inner, pBstrSource, errorCode, errors);
 }
示例#2
0
 /// <summary>
 /// Helper method to get the description of a enum value
 /// </summary>
 /// <param name="enumeratedValue">The enumerated value.</param>
 /// <returns>string description of the enum</returns>
 public static String GetEnumDescription(System.Enum enumeratedValue)
 {
     return enumeratedValue.GetDescription();
 }