Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Data / System / Data / Odbc / OdbcException.cs / 1 / OdbcException.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //[....] //----------------------------------------------------------------------------- using System; using System.ComponentModel; //Component using System.Collections; //ICollection using System.Data; using System.Data.Common; using System.Globalization; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Text; namespace System.Data.Odbc { [Serializable] #if WINFSInternalOnly internal #else public #endif sealed class OdbcException : System.Data.Common.DbException { OdbcErrorCollection odbcErrors = new OdbcErrorCollection(); ODBC32.RETCODE _retcode; // DO NOT REMOVE! only needed for serialization purposes, because Everett had it. static internal OdbcException CreateException(OdbcErrorCollection errors, ODBC32.RetCode retcode) { StringBuilder builder = new StringBuilder(); foreach (OdbcError error in errors) { if (builder.Length > 0) { builder.Append(Environment.NewLine); } builder.Append(Res.GetString(Res.Odbc_ExceptionMessage, ODBC32.RetcodeToString(retcode), error.SQLState, error.Message)); // MDAC 68337 } OdbcException exception = new OdbcException(builder.ToString(), errors); return exception; } internal OdbcException(string message, OdbcErrorCollection errors) : base(message) { odbcErrors = errors; HResult = HResults.OdbcException; } // runtime will call even if private... private OdbcException(SerializationInfo si, StreamingContext sc) : base(si, sc) { _retcode = (ODBC32.RETCODE) si.GetValue("odbcRetcode", typeof(ODBC32.RETCODE)); odbcErrors = (OdbcErrorCollection) si.GetValue("odbcErrors", typeof(OdbcErrorCollection)); HResult = HResults.OdbcException; } public OdbcErrorCollection Errors { get { return odbcErrors; } } [System.Security.Permissions.SecurityPermissionAttribute(System.Security.Permissions.SecurityAction.LinkDemand, Flags=System.Security.Permissions.SecurityPermissionFlag.SerializationFormatter)] override public void GetObjectData(SerializationInfo si, StreamingContext context) { // MDAC 72003 if (null == si) { throw new ArgumentNullException("si"); } si.AddValue("odbcRetcode", _retcode, typeof(ODBC32.RETCODE)); si.AddValue("odbcErrors", odbcErrors, typeof(OdbcErrorCollection)); base.GetObjectData(si, context); } // mdac bug 62559 - if we don't have it return nothing (empty string) override public string Source { get { if (0 < Errors.Count) { string source = Errors[0].Source; return ADP.IsEmpty(source) ? "" : source; // base.Source; } return ""; // base.Source; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //[....] //----------------------------------------------------------------------------- using System; using System.ComponentModel; //Component using System.Collections; //ICollection using System.Data; using System.Data.Common; using System.Globalization; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Text; namespace System.Data.Odbc { [Serializable] #if WINFSInternalOnly internal #else public #endif sealed class OdbcException : System.Data.Common.DbException { OdbcErrorCollection odbcErrors = new OdbcErrorCollection(); ODBC32.RETCODE _retcode; // DO NOT REMOVE! only needed for serialization purposes, because Everett had it. static internal OdbcException CreateException(OdbcErrorCollection errors, ODBC32.RetCode retcode) { StringBuilder builder = new StringBuilder(); foreach (OdbcError error in errors) { if (builder.Length > 0) { builder.Append(Environment.NewLine); } builder.Append(Res.GetString(Res.Odbc_ExceptionMessage, ODBC32.RetcodeToString(retcode), error.SQLState, error.Message)); // MDAC 68337 } OdbcException exception = new OdbcException(builder.ToString(), errors); return exception; } internal OdbcException(string message, OdbcErrorCollection errors) : base(message) { odbcErrors = errors; HResult = HResults.OdbcException; } // runtime will call even if private... private OdbcException(SerializationInfo si, StreamingContext sc) : base(si, sc) { _retcode = (ODBC32.RETCODE) si.GetValue("odbcRetcode", typeof(ODBC32.RETCODE)); odbcErrors = (OdbcErrorCollection) si.GetValue("odbcErrors", typeof(OdbcErrorCollection)); HResult = HResults.OdbcException; } public OdbcErrorCollection Errors { get { return odbcErrors; } } [System.Security.Permissions.SecurityPermissionAttribute(System.Security.Permissions.SecurityAction.LinkDemand, Flags=System.Security.Permissions.SecurityPermissionFlag.SerializationFormatter)] override public void GetObjectData(SerializationInfo si, StreamingContext context) { // MDAC 72003 if (null == si) { throw new ArgumentNullException("si"); } si.AddValue("odbcRetcode", _retcode, typeof(ODBC32.RETCODE)); si.AddValue("odbcErrors", odbcErrors, typeof(OdbcErrorCollection)); base.GetObjectData(si, context); } // mdac bug 62559 - if we don't have it return nothing (empty string) override public string Source { get { if (0 < Errors.Count) { string source = Errors[0].Source; return ADP.IsEmpty(source) ? "" : source; // base.Source; } return ""; // base.Source; } } } } // 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
- FixedHyperLink.cs
- ExceptionUtil.cs
- SectionUpdates.cs
- AsymmetricSignatureDeformatter.cs
- LightweightEntityWrapper.cs
- UnionCodeGroup.cs
- HtmlButton.cs
- ImportedNamespaceContextItem.cs
- ProxyFragment.cs
- PageCatalogPart.cs
- LookupBindingPropertiesAttribute.cs
- Pair.cs
- TreeView.cs
- DrawItemEvent.cs
- XmlReader.cs
- UmAlQuraCalendar.cs
- FullTextBreakpoint.cs
- MexServiceChannelBuilder.cs
- OdbcConnection.cs
- CellIdBoolean.cs
- MimeMapping.cs
- mediaeventshelper.cs
- CodeTypeMember.cs
- PoisonMessageException.cs
- AttachmentService.cs
- ConstructorExpr.cs
- DrawListViewSubItemEventArgs.cs
- NonNullItemCollection.cs
- SemanticResultValue.cs
- XmlILTrace.cs
- Util.cs
- DrawingImage.cs
- TreeWalker.cs
- XmlSchemaNotation.cs
- XmlExceptionHelper.cs
- SolidColorBrush.cs
- ReliabilityContractAttribute.cs
- _NestedSingleAsyncResult.cs
- ProfilePropertyMetadata.cs
- DataSourceControlBuilder.cs
- OpenFileDialog.cs
- EventSetter.cs
- ReadOnlyDictionary.cs
- OdbcCommandBuilder.cs
- RadioButtonStandardAdapter.cs
- DataStreams.cs
- QilLoop.cs
- DriveNotFoundException.cs
- UpdateManifestForBrowserApplication.cs
- SchemaImporter.cs
- ModelVisual3D.cs
- KeyConstraint.cs
- Int64Storage.cs
- CodeGroup.cs
- LocalizabilityAttribute.cs
- Imaging.cs
- IndexOutOfRangeException.cs
- ResourceDictionary.cs
- WindowsStatusBar.cs
- SamlAuthenticationStatement.cs
- DesignerVerbCollection.cs
- LineServices.cs
- ColorConvertedBitmap.cs
- ExpandableObjectConverter.cs
- XmlQueryTypeFactory.cs
- RoleExceptions.cs
- URLString.cs
- PolicyStatement.cs
- OrderedHashRepartitionEnumerator.cs
- CacheOutputQuery.cs
- TableNameAttribute.cs
- XPathExpr.cs
- SapiInterop.cs
- RegexTree.cs
- AnnouncementDispatcherAsyncResult.cs
- BuilderInfo.cs
- FileEnumerator.cs
- ObjRef.cs
- DataGridViewIntLinkedList.cs
- XmlAttributes.cs
- ZipIOFileItemStream.cs
- TiffBitmapDecoder.cs
- ModuleBuilder.cs
- DataPagerField.cs
- ListBox.cs
- PenContext.cs
- LocalizableAttribute.cs
- CopyCodeAction.cs
- CacheRequest.cs
- CharUnicodeInfo.cs
- MenuStrip.cs
- log.cs
- RuntimeConfigLKG.cs
- _OSSOCK.cs
- AppSettingsExpressionBuilder.cs
- MsmqHostedTransportManager.cs
- ScriptReferenceEventArgs.cs
- StreamProxy.cs
- Error.cs
- TabItem.cs