Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DrawingDrawingContext.cs
- EventLogConfiguration.cs
- PageClientProxyGenerator.cs
- DataGridHeaderBorder.cs
- ResourcesGenerator.cs
- FormViewPagerRow.cs
- FindCriteria11.cs
- ParameterBuilder.cs
- FocusWithinProperty.cs
- SSmlParser.cs
- Documentation.cs
- Configuration.cs
- RegexNode.cs
- SendKeys.cs
- _FixedSizeReader.cs
- XmlnsDictionary.cs
- XmlElementAttribute.cs
- PermissionRequestEvidence.cs
- HyperLinkStyle.cs
- XmlSchemaAnnotated.cs
- SafeUserTokenHandle.cs
- Variable.cs
- SqlCaseSimplifier.cs
- Timer.cs
- ECDiffieHellmanPublicKey.cs
- ConnectionPoolRegistry.cs
- BitVector32.cs
- FormsIdentity.cs
- DebugView.cs
- CodeRemoveEventStatement.cs
- Attachment.cs
- SHA384.cs
- InvariantComparer.cs
- DictionaryChange.cs
- RadioButton.cs
- HttpFileCollection.cs
- EncoderReplacementFallback.cs
- XmlSequenceWriter.cs
- CodePrimitiveExpression.cs
- DataGridRowHeaderAutomationPeer.cs
- SqlCacheDependencyDatabase.cs
- JournalEntryListConverter.cs
- ProcessModelSection.cs
- WorkflowClientDeliverMessageWrapper.cs
- XmlSchemaValidationException.cs
- Group.cs
- DataGridCellClipboardEventArgs.cs
- TextElementEnumerator.cs
- ComponentEditorForm.cs
- SqlCacheDependencyDatabaseCollection.cs
- XmlSchemaCollection.cs
- DocumentGridContextMenu.cs
- ElementsClipboardData.cs
- InvalidEnumArgumentException.cs
- ChannelManager.cs
- Table.cs
- ToolStripPanelCell.cs
- WebPageTraceListener.cs
- SoapProtocolReflector.cs
- EmbeddedMailObjectsCollection.cs
- ColumnTypeConverter.cs
- SecurityState.cs
- SubordinateTransaction.cs
- InternalConfigHost.cs
- Geometry3D.cs
- ISessionStateStore.cs
- DeviceFiltersSection.cs
- ClientEventManager.cs
- SecurityManager.cs
- Token.cs
- ComponentFactoryHelpers.cs
- Publisher.cs
- IRCollection.cs
- TableItemPattern.cs
- CopyAttributesAction.cs
- WebPartMenu.cs
- WarningException.cs
- AesCryptoServiceProvider.cs
- BindingNavigatorDesigner.cs
- SqlAliaser.cs
- SchemaMerger.cs
- ActivityDesignerResources.cs
- AlphabeticalEnumConverter.cs
- SafeThreadHandle.cs
- SafeRegistryHandle.cs
- RoleExceptions.cs
- ParseHttpDate.cs
- PartialCachingControl.cs
- TriggerActionCollection.cs
- _ProxyChain.cs
- XmlSchemaInclude.cs
- TimeSpan.cs
- TrustManagerMoreInformation.cs
- PkcsMisc.cs
- EntityDataSource.cs
- ThreadStartException.cs
- DefaultSection.cs
- PathGeometry.cs
- EndPoint.cs
- ClientSession.cs