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 / 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
- RectangleGeometry.cs
- GroupPartitionExpr.cs
- RawStylusActions.cs
- XmlDomTextWriter.cs
- Token.cs
- Command.cs
- AttributeEmitter.cs
- WindowsFormsHostPropertyMap.cs
- WinCategoryAttribute.cs
- ProtocolElementCollection.cs
- TreeNodeStyle.cs
- OrderedDictionaryStateHelper.cs
- EastAsianLunisolarCalendar.cs
- SqlXmlStorage.cs
- Deflater.cs
- DefaultBindingPropertyAttribute.cs
- SqlRetyper.cs
- DependencyPropertyDescriptor.cs
- ServiceDescriptions.cs
- NativeRecognizer.cs
- StylusButtonCollection.cs
- CompilerScope.Storage.cs
- WindowsContainer.cs
- ValueProviderWrapper.cs
- DataAdapter.cs
- Pts.cs
- Codec.cs
- VisualProxy.cs
- VariableQuery.cs
- DBCSCodePageEncoding.cs
- SmtpNetworkElement.cs
- IdentityHolder.cs
- TagMapInfo.cs
- DataGridViewCellParsingEventArgs.cs
- ExtentJoinTreeNode.cs
- UnsafeNativeMethods.cs
- WebControlAdapter.cs
- ConfigsHelper.cs
- TextFormatterHost.cs
- PeerNameRecord.cs
- complextypematerializer.cs
- SchemaSetCompiler.cs
- FileDialogCustomPlacesCollection.cs
- AvtEvent.cs
- ReadWriteSpinLock.cs
- CompiledIdentityConstraint.cs
- PagerSettings.cs
- UrlMappingsModule.cs
- DataObject.cs
- LineSegment.cs
- InternalCache.cs
- SymmetricAlgorithm.cs
- CodeMemberField.cs
- DecoratedNameAttribute.cs
- SyndicationItem.cs
- Utils.cs
- Solver.cs
- TemplateManager.cs
- SafeRightsManagementQueryHandle.cs
- CodeTypeReference.cs
- TextElement.cs
- InProcStateClientManager.cs
- Binding.cs
- MaterialGroup.cs
- WebPartTracker.cs
- KeyToListMap.cs
- SmiSettersStream.cs
- QuaternionRotation3D.cs
- StrokeCollectionConverter.cs
- TableHeaderCell.cs
- DoubleAnimationClockResource.cs
- SqlCachedBuffer.cs
- CompiledQuery.cs
- ToolStripItemCollection.cs
- NullableDecimalMinMaxAggregationOperator.cs
- XamlBuildTaskServices.cs
- followingsibling.cs
- Converter.cs
- PersonalizationDictionary.cs
- PointAnimationClockResource.cs
- SafeHandle.cs
- HttpContextWrapper.cs
- ActivityCodeDomSerializer.cs
- SqlUserDefinedTypeAttribute.cs
- RemoteTokenFactory.cs
- HScrollBar.cs
- TouchEventArgs.cs
- EntityContainer.cs
- ButtonRenderer.cs
- DesignerDataRelationship.cs
- ValidationRuleCollection.cs
- XmlTextReader.cs
- File.cs
- MarginCollapsingState.cs
- EventLogPermissionEntry.cs
- CompressEmulationStream.cs
- DataControlField.cs
- DiscoveryOperationContext.cs
- XamlGridLengthSerializer.cs
- SqlConnectionPoolProviderInfo.cs