Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Data / System / Data / OleDb / OleDbError.cs / 1305376 / OleDbError.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //[....] //----------------------------------------------------------------------------- namespace System.Data.OleDb { using System; using System.Data.Common; using System.Diagnostics; using System.Globalization; using System.Runtime.InteropServices; [Serializable] public sealed class OleDbError { readonly private string message; readonly private string source; readonly private string sqlState; readonly private int nativeError; internal OleDbError(UnsafeNativeMethods.IErrorRecords errorRecords, int index) { OleDbHResult hr; int lcid = System.Globalization.CultureInfo.CurrentCulture.LCID; Bid.Trace("\n"); UnsafeNativeMethods.IErrorInfo errorInfo = errorRecords.GetErrorInfo(index, lcid); if (null != errorInfo) { Bid.Trace(" \n"); hr = errorInfo.GetDescription(out this.message); Bid.Trace(" Message='%ls'\n", this.message); if (OleDbHResult.DB_E_NOLOCALE == hr) { // MDAC 87303 Bid.Trace(" ErrorInfo\n"); Marshal.ReleaseComObject(errorInfo); Bid.Trace(" \n"); lcid = SafeNativeMethods.GetUserDefaultLCID(); Bid.Trace(" LCID=%d\n", lcid); errorInfo = errorRecords.GetErrorInfo(index, lcid); if (null != errorInfo) { Bid.Trace(" \n"); hr = errorInfo.GetDescription(out this.message); Bid.Trace(" Message='%ls'\n", this.message); } } if ((hr < 0) && ADP.IsEmpty(this.message)) { this.message = ODB.FailedGetDescription(hr); } if (null != errorInfo) { Bid.Trace(" \n"); hr = errorInfo.GetSource(out this.source); Bid.Trace(" Source='%ls'\n", this.source); if (OleDbHResult.DB_E_NOLOCALE == hr) { // MDAC 87303 Marshal.ReleaseComObject(errorInfo); Bid.Trace(" \n"); lcid = SafeNativeMethods.GetUserDefaultLCID(); Bid.Trace(" LCID=%d\n", lcid); errorInfo = errorRecords.GetErrorInfo(index, lcid); if (null != errorInfo) { Bid.Trace(" \n"); hr = errorInfo.GetSource(out this.source); Bid.Trace(" Source='%ls'\n", this.source); } } if ((hr < 0) && ADP.IsEmpty(this.source)) { this.source = ODB.FailedGetSource(hr); } Bid.Trace(" ErrorInfo\n"); Marshal.ReleaseComObject(errorInfo); } } UnsafeNativeMethods.ISQLErrorInfo sqlErrorInfo; Bid.Trace(" IID_ISQLErrorInfo\n"); hr = errorRecords.GetCustomErrorObject(index, ref ODB.IID_ISQLErrorInfo, out sqlErrorInfo); if (null != sqlErrorInfo) { Bid.Trace(" \n"); this.nativeError = sqlErrorInfo.GetSQLInfo(out this.sqlState); Bid.Trace(" SQLErrorInfo\n"); Marshal.ReleaseComObject(sqlErrorInfo); } } public string Message { get { string message = this.message; return ((null != message) ? message : ADP.StrEmpty); } } public int NativeError { get { return this.nativeError; } } public string Source { get { string source = this.source; return ((null != source) ? source : ADP.StrEmpty); } } public string SQLState { get { string sqlState = this.sqlState; return ((null != sqlState) ? sqlState : ADP.StrEmpty); } } override public string ToString() { return Message; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //[....] //----------------------------------------------------------------------------- namespace System.Data.OleDb { using System; using System.Data.Common; using System.Diagnostics; using System.Globalization; using System.Runtime.InteropServices; [Serializable] public sealed class OleDbError { readonly private string message; readonly private string source; readonly private string sqlState; readonly private int nativeError; internal OleDbError(UnsafeNativeMethods.IErrorRecords errorRecords, int index) { OleDbHResult hr; int lcid = System.Globalization.CultureInfo.CurrentCulture.LCID; Bid.Trace("\n"); UnsafeNativeMethods.IErrorInfo errorInfo = errorRecords.GetErrorInfo(index, lcid); if (null != errorInfo) { Bid.Trace(" \n"); hr = errorInfo.GetDescription(out this.message); Bid.Trace(" Message='%ls'\n", this.message); if (OleDbHResult.DB_E_NOLOCALE == hr) { // MDAC 87303 Bid.Trace(" ErrorInfo\n"); Marshal.ReleaseComObject(errorInfo); Bid.Trace(" \n"); lcid = SafeNativeMethods.GetUserDefaultLCID(); Bid.Trace(" LCID=%d\n", lcid); errorInfo = errorRecords.GetErrorInfo(index, lcid); if (null != errorInfo) { Bid.Trace(" \n"); hr = errorInfo.GetDescription(out this.message); Bid.Trace(" Message='%ls'\n", this.message); } } if ((hr < 0) && ADP.IsEmpty(this.message)) { this.message = ODB.FailedGetDescription(hr); } if (null != errorInfo) { Bid.Trace(" \n"); hr = errorInfo.GetSource(out this.source); Bid.Trace(" Source='%ls'\n", this.source); if (OleDbHResult.DB_E_NOLOCALE == hr) { // MDAC 87303 Marshal.ReleaseComObject(errorInfo); Bid.Trace(" \n"); lcid = SafeNativeMethods.GetUserDefaultLCID(); Bid.Trace(" LCID=%d\n", lcid); errorInfo = errorRecords.GetErrorInfo(index, lcid); if (null != errorInfo) { Bid.Trace(" \n"); hr = errorInfo.GetSource(out this.source); Bid.Trace(" Source='%ls'\n", this.source); } } if ((hr < 0) && ADP.IsEmpty(this.source)) { this.source = ODB.FailedGetSource(hr); } Bid.Trace(" ErrorInfo\n"); Marshal.ReleaseComObject(errorInfo); } } UnsafeNativeMethods.ISQLErrorInfo sqlErrorInfo; Bid.Trace(" IID_ISQLErrorInfo\n"); hr = errorRecords.GetCustomErrorObject(index, ref ODB.IID_ISQLErrorInfo, out sqlErrorInfo); if (null != sqlErrorInfo) { Bid.Trace(" \n"); this.nativeError = sqlErrorInfo.GetSQLInfo(out this.sqlState); Bid.Trace(" SQLErrorInfo\n"); Marshal.ReleaseComObject(sqlErrorInfo); } } public string Message { get { string message = this.message; return ((null != message) ? message : ADP.StrEmpty); } } public int NativeError { get { return this.nativeError; } } public string Source { get { string source = this.source; return ((null != source) ? source : ADP.StrEmpty); } } public string SQLState { get { string sqlState = this.sqlState; return ((null != sqlState) ? sqlState : ADP.StrEmpty); } } override public string ToString() { return Message; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- httpstaticobjectscollection.cs
- SapiInterop.cs
- EventDescriptorCollection.cs
- CqlParser.cs
- EnvironmentPermission.cs
- DataGridViewRowPostPaintEventArgs.cs
- ThreadWorkerController.cs
- Currency.cs
- PathTooLongException.cs
- NotifyCollectionChangedEventArgs.cs
- InternalCache.cs
- WorkerRequest.cs
- LinkClickEvent.cs
- RegexBoyerMoore.cs
- FileFormatException.cs
- OdbcRowUpdatingEvent.cs
- X509ChainPolicy.cs
- BufferModeSettings.cs
- DescendantBaseQuery.cs
- UIPermission.cs
- TextEditorDragDrop.cs
- SqlDataReaderSmi.cs
- Int16Converter.cs
- PathData.cs
- ChannelDispatcher.cs
- AnimationStorage.cs
- ProfileSettingsCollection.cs
- ContainsSearchOperator.cs
- DataGridViewControlCollection.cs
- TransformerInfoCollection.cs
- TableAdapterManagerNameHandler.cs
- TemplateControl.cs
- MessageSecurityOverMsmq.cs
- SecUtil.cs
- LocalizedNameDescriptionPair.cs
- InvokeGenerator.cs
- GradientBrush.cs
- Container.cs
- WindowsContainer.cs
- BamlTreeNode.cs
- SymbolType.cs
- Size.cs
- ConnectionManagementSection.cs
- DoubleCollectionValueSerializer.cs
- DaylightTime.cs
- cookiecontainer.cs
- HttpException.cs
- WindowsPrincipal.cs
- CodeArrayCreateExpression.cs
- DbXmlEnabledProviderManifest.cs
- DataFieldConverter.cs
- TripleDES.cs
- InputMethodStateChangeEventArgs.cs
- CachedResourceDictionaryExtension.cs
- LeftCellWrapper.cs
- SoapSchemaMember.cs
- ActivityDesignerLayoutSerializers.cs
- AccessibilityApplicationManager.cs
- AddInEnvironment.cs
- PropertyIDSet.cs
- HtmlMeta.cs
- DrawListViewItemEventArgs.cs
- SHA512CryptoServiceProvider.cs
- SqlCacheDependency.cs
- TrackingExtract.cs
- Int32.cs
- UnionExpr.cs
- PolyQuadraticBezierSegment.cs
- GridViewRowEventArgs.cs
- WebPartConnectionsCloseVerb.cs
- Vector3DValueSerializer.cs
- XPathLexer.cs
- NavigatorOutput.cs
- WaitForChangedResult.cs
- ViewLoader.cs
- X509ServiceCertificateAuthentication.cs
- mediaeventshelper.cs
- HandledEventArgs.cs
- StartUpEventArgs.cs
- PropertyGrid.cs
- WrapPanel.cs
- _DomainName.cs
- XmlWhitespace.cs
- RtfToXamlReader.cs
- SystemBrushes.cs
- IgnoreSectionHandler.cs
- TextRangeProviderWrapper.cs
- RoleManagerModule.cs
- BaseDataBoundControl.cs
- ItemsControl.cs
- BCLDebug.cs
- StylusPointProperties.cs
- BulletedListEventArgs.cs
- XmlDataSourceNodeDescriptor.cs
- FragmentQueryKB.cs
- CompilationSection.cs
- ContainsSearchOperator.cs
- DataGridViewCellStyle.cs
- Attributes.cs
- DropDownHolder.cs