internal OleDbError(UnsafeNativeMethods.IErrorRecords errorRecords, int index) { OleDbHResult hr; int lcid = System.Globalization.CultureInfo.CurrentCulture.LCID; UnsafeNativeMethods.IErrorInfo errorInfo = errorRecords.GetErrorInfo(index, lcid); if (null != errorInfo) { hr = errorInfo.GetDescription(out this.message); if (OleDbHResult.DB_E_NOLOCALE == hr) { Marshal.ReleaseComObject(errorInfo); lcid = Interop.Kernel32.GetUserDefaultLCID(); errorInfo = errorRecords.GetErrorInfo(index, lcid); if (null != errorInfo) { hr = errorInfo.GetDescription(out this.message); } } if ((hr < 0) && ADP.IsEmpty(this.message)) { this.message = ODB.FailedGetDescription(hr); } if (null != errorInfo) { hr = errorInfo.GetSource(out this.source); if (OleDbHResult.DB_E_NOLOCALE == hr) { Marshal.ReleaseComObject(errorInfo); lcid = Interop.Kernel32.GetUserDefaultLCID(); errorInfo = errorRecords.GetErrorInfo(index, lcid); if (null != errorInfo) { hr = errorInfo.GetSource(out this.source); } } if ((hr < 0) && ADP.IsEmpty(this.source)) { this.source = ODB.FailedGetSource(hr); } Marshal.ReleaseComObject(errorInfo !); } } UnsafeNativeMethods.ISQLErrorInfo sqlErrorInfo; errorRecords.GetCustomErrorObject(index, ref ODB.IID_ISQLErrorInfo, out sqlErrorInfo); if (null != sqlErrorInfo) { this.nativeError = sqlErrorInfo.GetSQLInfo(out this.sqlState); Marshal.ReleaseComObject(sqlErrorInfo); } }
internal OleDbError(UnsafeNativeMethods.IErrorRecords errorRecords, int index) { OleDbHResult hr; int lcid = System.Globalization.CultureInfo.CurrentCulture.LCID; Bid.Trace("<oledb.IErrorRecords.GetErrorInfo|API|OS>\n"); UnsafeNativeMethods.IErrorInfo errorInfo = errorRecords.GetErrorInfo(index, lcid); if (null != errorInfo) { Bid.Trace("<oledb.IErrorInfo.GetDescription|API|OS>\n"); hr = errorInfo.GetDescription(out this.message); Bid.Trace("<oledb.IErrorInfo.GetDescription|API|OS|RET> Message='%ls'\n", this.message); if (OleDbHResult.DB_E_NOLOCALE == hr) // MDAC 87303 { Bid.Trace("<oledb.ReleaseComObject|API|OS> ErrorInfo\n"); Marshal.ReleaseComObject(errorInfo); Bid.Trace("<oledb.Kernel32.GetUserDefaultLCID|API|OS>\n"); lcid = SafeNativeMethods.GetUserDefaultLCID(); Bid.Trace("<oledb.IErrorRecords.GetErrorInfo|API|OS> LCID=%d\n", lcid); errorInfo = errorRecords.GetErrorInfo(index, lcid); if (null != errorInfo) { Bid.Trace("<oledb.IErrorInfo.GetDescription|API|OS>\n"); hr = errorInfo.GetDescription(out this.message); Bid.Trace("<oledb.IErrorInfo.GetDescription|API|OS|RET> Message='%ls'\n", this.message); } } if ((hr < 0) && ADP.IsEmpty(this.message)) { this.message = ODB.FailedGetDescription(hr); } if (null != errorInfo) { Bid.Trace("<oledb.IErrorInfo.GetSource|API|OS>\n"); hr = errorInfo.GetSource(out this.source); Bid.Trace("<oledb.IErrorInfo.GetSource|API|OS|RET> Source='%ls'\n", this.source); if (OleDbHResult.DB_E_NOLOCALE == hr) // MDAC 87303 { Marshal.ReleaseComObject(errorInfo); Bid.Trace("<oledb.Kernel32.GetUserDefaultLCID|API|OS>\n"); lcid = SafeNativeMethods.GetUserDefaultLCID(); Bid.Trace("<oledb.IErrorRecords.GetErrorInfo|API|OS> LCID=%d\n", lcid); errorInfo = errorRecords.GetErrorInfo(index, lcid); if (null != errorInfo) { Bid.Trace("<oledb.IErrorInfo.GetSource|API|OS>\n"); hr = errorInfo.GetSource(out this.source); Bid.Trace("<oledb.IErrorInfo.GetSource|API|OS|RET> Source='%ls'\n", this.source); } } if ((hr < 0) && ADP.IsEmpty(this.source)) { this.source = ODB.FailedGetSource(hr); } Bid.Trace("<oledb.Marshal.ReleaseComObject|API|OS> ErrorInfo\n"); Marshal.ReleaseComObject(errorInfo); } } UnsafeNativeMethods.ISQLErrorInfo sqlErrorInfo; Bid.Trace("<oledb.IErrorRecords.GetCustomErrorObject|API|OS> IID_ISQLErrorInfo\n"); hr = errorRecords.GetCustomErrorObject(index, ref ODB.IID_ISQLErrorInfo, out sqlErrorInfo); if (null != sqlErrorInfo) { Bid.Trace("<oledb.ISQLErrorInfo.GetSQLInfo|API|OS>\n"); this.nativeError = sqlErrorInfo.GetSQLInfo(out this.sqlState); Bid.Trace("<oledb.ReleaseComObject|API|OS> SQLErrorInfo\n"); Marshal.ReleaseComObject(sqlErrorInfo); } }
internal OleDbError(UnsafeNativeMethods.IErrorRecords errorRecords, int index) { OleDbHResult description; UnsafeNativeMethods.ISQLErrorInfo info2; int lCID = CultureInfo.CurrentCulture.LCID; Bid.Trace("<oledb.IErrorRecords.GetErrorInfo|API|OS>\n"); UnsafeNativeMethods.IErrorInfo errorInfo = errorRecords.GetErrorInfo(index, lCID); if (errorInfo != null) { Bid.Trace("<oledb.IErrorInfo.GetDescription|API|OS>\n"); description = errorInfo.GetDescription(out this.message); Bid.Trace("<oledb.IErrorInfo.GetDescription|API|OS|RET> Message='%ls'\n", this.message); if (OleDbHResult.DB_E_NOLOCALE == description) { Bid.Trace("<oledb.ReleaseComObject|API|OS> ErrorInfo\n"); Marshal.ReleaseComObject(errorInfo); Bid.Trace("<oledb.Kernel32.GetUserDefaultLCID|API|OS>\n"); lCID = SafeNativeMethods.GetUserDefaultLCID(); Bid.Trace("<oledb.IErrorRecords.GetErrorInfo|API|OS> LCID=%d\n", lCID); errorInfo = errorRecords.GetErrorInfo(index, lCID); if (errorInfo != null) { Bid.Trace("<oledb.IErrorInfo.GetDescription|API|OS>\n"); description = errorInfo.GetDescription(out this.message); Bid.Trace("<oledb.IErrorInfo.GetDescription|API|OS|RET> Message='%ls'\n", this.message); } } if ((description < OleDbHResult.S_OK) && ADP.IsEmpty(this.message)) { this.message = ODB.FailedGetDescription(description); } if (errorInfo != null) { Bid.Trace("<oledb.IErrorInfo.GetSource|API|OS>\n"); description = errorInfo.GetSource(out this.source); Bid.Trace("<oledb.IErrorInfo.GetSource|API|OS|RET> Source='%ls'\n", this.source); if (OleDbHResult.DB_E_NOLOCALE == description) { Marshal.ReleaseComObject(errorInfo); Bid.Trace("<oledb.Kernel32.GetUserDefaultLCID|API|OS>\n"); lCID = SafeNativeMethods.GetUserDefaultLCID(); Bid.Trace("<oledb.IErrorRecords.GetErrorInfo|API|OS> LCID=%d\n", lCID); errorInfo = errorRecords.GetErrorInfo(index, lCID); if (errorInfo != null) { Bid.Trace("<oledb.IErrorInfo.GetSource|API|OS>\n"); description = errorInfo.GetSource(out this.source); Bid.Trace("<oledb.IErrorInfo.GetSource|API|OS|RET> Source='%ls'\n", this.source); } } if ((description < OleDbHResult.S_OK) && ADP.IsEmpty(this.source)) { this.source = ODB.FailedGetSource(description); } Bid.Trace("<oledb.Marshal.ReleaseComObject|API|OS> ErrorInfo\n"); Marshal.ReleaseComObject(errorInfo); } } Bid.Trace("<oledb.IErrorRecords.GetCustomErrorObject|API|OS> IID_ISQLErrorInfo\n"); description = errorRecords.GetCustomErrorObject(index, ref ODB.IID_ISQLErrorInfo, out info2); if (info2 != null) { Bid.Trace("<oledb.ISQLErrorInfo.GetSQLInfo|API|OS>\n"); this.nativeError = info2.GetSQLInfo(out this.sqlState); Bid.Trace("<oledb.ReleaseComObject|API|OS> SQLErrorInfo\n"); Marshal.ReleaseComObject(info2); } }
/// <include file='doc\OleDbError.uex' path='docs/doc[@for="OleDbError.GetErrorInfo"]/*' /> private void GetErrorInfo(UnsafeNativeMethods.IErrorRecords errorRecords, int index) { int lcid = System.Globalization.CultureInfo.CurrentCulture.LCID; UnsafeNativeMethods.IErrorInfo errorInfo = null; int hr = errorRecords.GetErrorInfo(index, lcid, out errorInfo); if ((0 <= hr) && (null != errorInfo)) { #if DEBUG ODB.Trace_Begin(4, "IErrorInfo", "GetDescription"); #endif hr = errorInfo.GetDescription(out message); #if DEBUG ODB.Trace_End(4, "IErrorInfo", "GetDescription", hr, this.message); #endif if (ODB.DB_E_NOLOCALE == hr) { // MDAC 87303 Marshal.ReleaseComObject(errorInfo); #if DEBUG ODB.Trace_Begin(4, "Kernel32", "GetUserDefaultLCID"); #endif lcid = UnsafeNativeMethods.GetUserDefaultLCID(); #if DEBUG ODB.Trace_End(4, "Kernel32", "GetUserDefaultLCID", lcid); ODB.Trace_Begin(4, "IErrorRecords", "GetErrorInfo"); #endif hr = errorRecords.GetErrorInfo(index, lcid, out errorInfo); #if DEBUG ODB.Trace_End(4, "IErrorRecords", "GetErrorInfo", hr); #endif if ((0 <= hr) && (null != errorInfo)) { #if DEBUG ODB.Trace_Begin(4, "IErrorInfo", "GetDescription", "retry"); #endif hr = errorInfo.GetDescription(out this.message); #if DEBUG ODB.Trace_End(4, "IErrorInfo", "GetDescription", hr, this.message); #endif } } if ((hr < 0) && ADP.IsEmpty(this.message)) { this.message = ODB.FailedGetDescription(hr); } if (null != errorInfo) { #if DEBUG ODB.Trace_Begin(4, "IErrorInfo", "GetSource"); #endif hr = errorInfo.GetSource(out this.source); #if DEBUG ODB.Trace_End(4, "IErrorInfo", "GetSource", hr, this.source); #endif if (ODB.DB_E_NOLOCALE == hr) { // MDAC 87303 Marshal.ReleaseComObject(errorInfo); #if DEBUG ODB.Trace_Begin(4, "Kernel32", "GetUserDefaultLCID"); #endif lcid = UnsafeNativeMethods.GetUserDefaultLCID(); #if DEBUG ODB.Trace_End(4, "Kernel32", "GetUserDefaultLCID", lcid); ODB.Trace_Begin(4, "IErrorRecords", "GetErrorInfo"); #endif hr = errorRecords.GetErrorInfo(index, lcid, out errorInfo); #if DEBUG ODB.Trace_End(4, "IErrorRecords", "GetErrorInfo", hr); #endif if ((0 <= hr) && (null != errorInfo)) { #if DEBUG ODB.Trace_Begin(4, "IErrorInfo", "GetSource", "retry"); #endif hr = errorInfo.GetSource(out this.source); #if DEBUG ODB.Trace_End(4, "IErrorInfo", "GetSource", hr, this.source); #endif } } if ((hr < 0) && ADP.IsEmpty(this.source)) { this.source = ODB.FailedGetSource(hr); } Marshal.ReleaseComObject(errorInfo); } } }