Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Data / System / Data / SqlClient / SqlException.cs / 1 / SqlException.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //[....] //----------------------------------------------------------------------------- namespace System.Data.SqlClient { using System; using System.ComponentModel; using System.Data.Common; using System.Diagnostics; using System.Globalization; using System.Runtime.Serialization; using System.Text; // StringBuilder [Serializable] #if WINFSInternalOnly internal #else public #endif sealed class SqlException : System.Data.Common.DbException { private SqlErrorCollection _errors; private SqlException(string message, SqlErrorCollection errorCollection) : base(message) { HResult = HResults.SqlException; _errors = errorCollection; } // runtime will call even if private... private SqlException(SerializationInfo si, StreamingContext sc) : base(si, sc) { _errors = (SqlErrorCollection) si.GetValue("Errors", typeof(SqlErrorCollection)); HResult = HResults.SqlException; } [System.Security.Permissions.SecurityPermissionAttribute(System.Security.Permissions.SecurityAction.LinkDemand, Flags=System.Security.Permissions.SecurityPermissionFlag.SerializationFormatter)] override public void GetObjectData(SerializationInfo si, StreamingContext context) { if (null == si) { throw new ArgumentNullException("si"); } si.AddValue("Errors", _errors, typeof(SqlErrorCollection)); base.GetObjectData(si, context); } [ DesignerSerializationVisibility(DesignerSerializationVisibility.Content) ] public SqlErrorCollection Errors { get { if (_errors == null) { _errors = new SqlErrorCollection(); } return _errors; } } /*virtual protected*/private bool ShouldSerializeErrors() { // MDAC 65548 return ((null != _errors) && (0 < _errors.Count)); } public byte Class { get { return this.Errors[0].Class;} } public int LineNumber { get { return this.Errors[0].LineNumber;} } public int Number { get { return this.Errors[0].Number;} } public string Procedure { get { return this.Errors[0].Procedure;} } public string Server { get { return this.Errors[0].Server;} } public byte State { get { return this.Errors[0].State;} } override public string Source { get { return this.Errors[0].Source;} } static internal SqlException CreateException(SqlErrorCollection errorCollection, string serverVersion) { Debug.Assert(null != errorCollection, "no errorCollection?"); // concat all messages together MDAC 65533 StringBuilder message = new StringBuilder(); for (int i = 0; i < errorCollection.Count; i++) { if (i > 0) { message.Append(Environment.NewLine); } message.Append(errorCollection[i].Message); } SqlException exception = new SqlException(message.ToString(), errorCollection); exception.Data.Add("HelpLink.ProdName", "Microsoft SQL Server"); if (!ADP.IsEmpty(serverVersion)) { exception.Data.Add("HelpLink.ProdVer", serverVersion); } exception.Data.Add("HelpLink.EvtSrc", "MSSQLServer"); exception.Data.Add("HelpLink.EvtID", errorCollection[0].Number.ToString(CultureInfo.InvariantCulture)); exception.Data.Add("HelpLink.BaseHelpUrl", "http://go.microsoft.com/fwlink"); exception.Data.Add("HelpLink.LinkId", "20476"); return exception; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //[....] //----------------------------------------------------------------------------- namespace System.Data.SqlClient { using System; using System.ComponentModel; using System.Data.Common; using System.Diagnostics; using System.Globalization; using System.Runtime.Serialization; using System.Text; // StringBuilder [Serializable] #if WINFSInternalOnly internal #else public #endif sealed class SqlException : System.Data.Common.DbException { private SqlErrorCollection _errors; private SqlException(string message, SqlErrorCollection errorCollection) : base(message) { HResult = HResults.SqlException; _errors = errorCollection; } // runtime will call even if private... private SqlException(SerializationInfo si, StreamingContext sc) : base(si, sc) { _errors = (SqlErrorCollection) si.GetValue("Errors", typeof(SqlErrorCollection)); HResult = HResults.SqlException; } [System.Security.Permissions.SecurityPermissionAttribute(System.Security.Permissions.SecurityAction.LinkDemand, Flags=System.Security.Permissions.SecurityPermissionFlag.SerializationFormatter)] override public void GetObjectData(SerializationInfo si, StreamingContext context) { if (null == si) { throw new ArgumentNullException("si"); } si.AddValue("Errors", _errors, typeof(SqlErrorCollection)); base.GetObjectData(si, context); } [ DesignerSerializationVisibility(DesignerSerializationVisibility.Content) ] public SqlErrorCollection Errors { get { if (_errors == null) { _errors = new SqlErrorCollection(); } return _errors; } } /*virtual protected*/private bool ShouldSerializeErrors() { // MDAC 65548 return ((null != _errors) && (0 < _errors.Count)); } public byte Class { get { return this.Errors[0].Class;} } public int LineNumber { get { return this.Errors[0].LineNumber;} } public int Number { get { return this.Errors[0].Number;} } public string Procedure { get { return this.Errors[0].Procedure;} } public string Server { get { return this.Errors[0].Server;} } public byte State { get { return this.Errors[0].State;} } override public string Source { get { return this.Errors[0].Source;} } static internal SqlException CreateException(SqlErrorCollection errorCollection, string serverVersion) { Debug.Assert(null != errorCollection, "no errorCollection?"); // concat all messages together MDAC 65533 StringBuilder message = new StringBuilder(); for (int i = 0; i < errorCollection.Count; i++) { if (i > 0) { message.Append(Environment.NewLine); } message.Append(errorCollection[i].Message); } SqlException exception = new SqlException(message.ToString(), errorCollection); exception.Data.Add("HelpLink.ProdName", "Microsoft SQL Server"); if (!ADP.IsEmpty(serverVersion)) { exception.Data.Add("HelpLink.ProdVer", serverVersion); } exception.Data.Add("HelpLink.EvtSrc", "MSSQLServer"); exception.Data.Add("HelpLink.EvtID", errorCollection[0].Number.ToString(CultureInfo.InvariantCulture)); exception.Data.Add("HelpLink.BaseHelpUrl", "http://go.microsoft.com/fwlink"); exception.Data.Add("HelpLink.LinkId", "20476"); return exception; } } } // 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
- PointCollection.cs
- TraceLog.cs
- ToolBarDesigner.cs
- MsmqQueue.cs
- DataControlFieldCollection.cs
- figurelengthconverter.cs
- EncodedStreamFactory.cs
- HwndHost.cs
- ColorAnimationBase.cs
- WriteStateInfoBase.cs
- HttpPostedFile.cs
- RegisteredExpandoAttribute.cs
- WebSysDisplayNameAttribute.cs
- HandleExceptionArgs.cs
- ContentIterators.cs
- DummyDataSource.cs
- EventLogPermission.cs
- ActivityTypeDesigner.xaml.cs
- XmlChildEnumerator.cs
- DeviceSpecificChoiceCollection.cs
- BufferModeSettings.cs
- TextSpan.cs
- GraphicsContainer.cs
- IgnoreFlushAndCloseStream.cs
- RemoteWebConfigurationHost.cs
- ElapsedEventArgs.cs
- XsdBuilder.cs
- MetadataCache.cs
- __Error.cs
- EntityContainerEntitySetDefiningQuery.cs
- CatalogPartChrome.cs
- TextStore.cs
- DispatcherHooks.cs
- StyleConverter.cs
- ItemMap.cs
- WebScriptEnablingBehavior.cs
- ConstructorNeedsTagAttribute.cs
- Control.cs
- SimpleBitVector32.cs
- util.cs
- HtmlLiteralTextAdapter.cs
- IndexOutOfRangeException.cs
- ToolStrip.cs
- VBCodeProvider.cs
- ChineseLunisolarCalendar.cs
- RolePrincipal.cs
- SQLConvert.cs
- CryptoKeySecurity.cs
- Sql8ConformanceChecker.cs
- TypeHelpers.cs
- indexingfiltermarshaler.cs
- ApplicationServiceHelper.cs
- AnnotationResource.cs
- DescendentsWalker.cs
- WebSysDefaultValueAttribute.cs
- ManagedFilter.cs
- DisableDpiAwarenessAttribute.cs
- TypeBinaryExpression.cs
- MenuTracker.cs
- XPathCompiler.cs
- Atom10FormatterFactory.cs
- CompositeControlDesigner.cs
- OrCondition.cs
- TextDecorationUnitValidation.cs
- XPathScanner.cs
- FloaterBaseParagraph.cs
- TextTreeUndo.cs
- X500Name.cs
- PointAnimationUsingPath.cs
- ConditionalAttribute.cs
- Semaphore.cs
- X509Utils.cs
- SmiMetaDataProperty.cs
- Currency.cs
- PreDigestedSignedInfo.cs
- KeyValuePair.cs
- LockingPersistenceProvider.cs
- HostedController.cs
- QilFactory.cs
- EmptyEnumerator.cs
- SqlParameter.cs
- FrameworkContentElementAutomationPeer.cs
- PersonalizationStateQuery.cs
- PatternMatcher.cs
- RenderData.cs
- ConfigurationStrings.cs
- WeakEventManager.cs
- TreeView.cs
- WorkflowPersistenceService.cs
- RootProfilePropertySettingsCollection.cs
- XmlUrlResolver.cs
- DataObjectFieldAttribute.cs
- HtmlToClrEventProxy.cs
- unsafenativemethodsother.cs
- PassportAuthenticationModule.cs
- PageClientProxyGenerator.cs
- ByteStack.cs
- BindingMAnagerBase.cs
- FieldAccessException.cs
- FamilyMapCollection.cs