Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Data / System / Data / Odbc / OdbcException.cs / 1305376 / 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] public 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] public 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
- CounterSample.cs
- connectionpool.cs
- WebPartCatalogCloseVerb.cs
- XPathItem.cs
- WindowsServiceCredential.cs
- TypeSystem.cs
- DocumentManager.cs
- ViewStateException.cs
- SoapHeaderException.cs
- PackagePart.cs
- FixedSOMTable.cs
- ObjectDataSourceMethodEventArgs.cs
- WizardStepCollectionEditor.cs
- BuildProviderCollection.cs
- NetMsmqBindingElement.cs
- ConstrainedDataObject.cs
- EntityCollection.cs
- SrgsSubset.cs
- DataSourceControl.cs
- TypeSystemProvider.cs
- TextChange.cs
- XamlTemplateSerializer.cs
- EncoderNLS.cs
- TemplateNameScope.cs
- DrawingImage.cs
- Span.cs
- Maps.cs
- HMACSHA1.cs
- ToolStripSeparatorRenderEventArgs.cs
- AttributeEmitter.cs
- AsyncStreamReader.cs
- MenuEventArgs.cs
- ParallelQuery.cs
- CallbackException.cs
- ApplyTemplatesAction.cs
- AdPostCacheSubstitution.cs
- WindowsIdentity.cs
- ExtensionQuery.cs
- StickyNoteContentControl.cs
- FontWeightConverter.cs
- FieldBuilder.cs
- BoundingRectTracker.cs
- IBuiltInEvidence.cs
- DataTableMapping.cs
- SimpleWebHandlerParser.cs
- SettingsBindableAttribute.cs
- StylesEditorDialog.cs
- BooleanConverter.cs
- Dictionary.cs
- DbBuffer.cs
- InvalidEnumArgumentException.cs
- AuthenticationException.cs
- UnmanagedBitmapWrapper.cs
- TextTreeObjectNode.cs
- Socket.cs
- Stream.cs
- TrackingMemoryStream.cs
- ParserContext.cs
- TypeViewSchema.cs
- ProvidersHelper.cs
- AncestorChangedEventArgs.cs
- HebrewNumber.cs
- StreamGeometry.cs
- ExtractCollection.cs
- Overlapped.cs
- FormViewCommandEventArgs.cs
- TextContainerHelper.cs
- wgx_render.cs
- PrintPreviewGraphics.cs
- SelectionEditingBehavior.cs
- DefaultClaimSet.cs
- altserialization.cs
- ImageFormatConverter.cs
- PowerModeChangedEventArgs.cs
- SimpleType.cs
- Convert.cs
- COAUTHINFO.cs
- HttpResponseHeader.cs
- ActivityBuilder.cs
- SerializationException.cs
- FileSystemEventArgs.cs
- XmlArrayItemAttributes.cs
- AnonymousIdentificationSection.cs
- ResourceAttributes.cs
- Simplifier.cs
- ClassicBorderDecorator.cs
- OdbcCommandBuilder.cs
- DictionaryContent.cs
- ProcessModelInfo.cs
- WebServiceReceiveDesigner.cs
- WindowsPrincipal.cs
- FormatterServices.cs
- DataProtectionSecurityStateEncoder.cs
- EditorOptionAttribute.cs
- DocumentXmlWriter.cs
- DataGridRow.cs
- LockCookie.cs
- SchemaTableOptionalColumn.cs
- EpmTargetTree.cs
- DataGridViewCellStyle.cs