Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / Data / System / Data / OleDb / OleDbError.cs / 1 / 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] #if WINFSInternalOnly internal #else public #endif 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] #if WINFSInternalOnly internal #else public #endif 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
- CodeSnippetExpression.cs
- ResourceDictionary.cs
- CheckBox.cs
- WebPartDisplayModeCancelEventArgs.cs
- SamlSecurityTokenAuthenticator.cs
- StoreAnnotationsMap.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- ValidationRule.cs
- XmlExceptionHelper.cs
- StdValidatorsAndConverters.cs
- LinearGradientBrush.cs
- SimpleType.cs
- EventDescriptorCollection.cs
- MinimizableAttributeTypeConverter.cs
- SimplePropertyEntry.cs
- ImageListUtils.cs
- NativeMethods.cs
- SqlDelegatedTransaction.cs
- TripleDES.cs
- SchemaNotation.cs
- PersonalizationAdministration.cs
- ClientScriptItem.cs
- TcpAppDomainProtocolHandler.cs
- Model3DGroup.cs
- Evidence.cs
- LongTypeConverter.cs
- XmlSchemaObject.cs
- ServiceBehaviorElement.cs
- DataGridViewControlCollection.cs
- InternalResources.cs
- TraceListeners.cs
- SecurityKeyIdentifierClause.cs
- Preprocessor.cs
- _IPv4Address.cs
- HasCopySemanticsAttribute.cs
- UmAlQuraCalendar.cs
- DesignTimeTemplateParser.cs
- XmlCompatibilityReader.cs
- StringFreezingAttribute.cs
- CountdownEvent.cs
- SchemaImporterExtension.cs
- TreeChangeInfo.cs
- DataRelation.cs
- XsdCachingReader.cs
- UnmanagedMarshal.cs
- ImageFormatConverter.cs
- CharKeyFrameCollection.cs
- ChtmlCommandAdapter.cs
- AdvancedBindingEditor.cs
- FlowDocumentView.cs
- Vector3DValueSerializer.cs
- Guid.cs
- Quaternion.cs
- Int16.cs
- KeyInterop.cs
- CompoundFileDeflateTransform.cs
- DependencyObjectProvider.cs
- EventListenerClientSide.cs
- XLinq.cs
- ProtectedConfiguration.cs
- GenerateScriptTypeAttribute.cs
- SetMemberBinder.cs
- EventRoute.cs
- IpcServerChannel.cs
- CollectionConverter.cs
- SaveFileDialog.cs
- StateDesignerConnector.cs
- BaseTemplateBuildProvider.cs
- ServiceHttpModule.cs
- MethodBuilder.cs
- Int32Animation.cs
- CreateParams.cs
- ArgumentException.cs
- XmlSchemaComplexContentExtension.cs
- RelationshipEnd.cs
- Baml2006KnownTypes.cs
- WebEvents.cs
- MethodBuilderInstantiation.cs
- XmlRawWriter.cs
- AlphabetConverter.cs
- CapabilitiesUse.cs
- ClientSponsor.cs
- BreakSafeBase.cs
- ColorConvertedBitmap.cs
- XmlSchemaNotation.cs
- SafeProcessHandle.cs
- PauseStoryboard.cs
- figurelengthconverter.cs
- Style.cs
- XomlCompiler.cs
- ContextMenuStrip.cs
- DataBindingCollection.cs
- WsatStrings.cs
- MouseCaptureWithinProperty.cs
- ProtocolsConfigurationHandler.cs
- DescendentsWalkerBase.cs
- SecurityCredentialsManager.cs
- Calendar.cs
- IndependentlyAnimatedPropertyMetadata.cs
- HttpApplicationStateBase.cs