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 / 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
- _NestedMultipleAsyncResult.cs
- TextPointer.cs
- MatrixIndependentAnimationStorage.cs
- PeerApplicationLaunchInfo.cs
- OdbcDataReader.cs
- TransformPattern.cs
- TransformCryptoHandle.cs
- ScaleTransform3D.cs
- TemplatedAdorner.cs
- ToolStripPanelRow.cs
- SafeHandles.cs
- DefaultObjectMappingItemCollection.cs
- ProxyGenerationError.cs
- AdornedElementPlaceholder.cs
- DbBuffer.cs
- GlobalItem.cs
- ViewGenerator.cs
- MonitoringDescriptionAttribute.cs
- ContractUtils.cs
- HotSpotCollection.cs
- CorrelationRequestContext.cs
- ModelServiceImpl.cs
- TerminatorSinks.cs
- GroupBoxRenderer.cs
- CodeConstructor.cs
- DbResourceAllocator.cs
- SqlNamer.cs
- ToggleProviderWrapper.cs
- BamlResourceDeserializer.cs
- WsrmMessageInfo.cs
- DirtyTextRange.cs
- InvalidAsynchronousStateException.cs
- FontInfo.cs
- StringSource.cs
- KerberosSecurityTokenAuthenticator.cs
- CodePageUtils.cs
- TcpPortSharing.cs
- MarkupProperty.cs
- RelationshipSet.cs
- BrowserCapabilitiesFactory35.cs
- DifferencingCollection.cs
- PeerChannelFactory.cs
- DataGridViewCellStateChangedEventArgs.cs
- RoutedEventHandlerInfo.cs
- DataGrid.cs
- RoutedCommand.cs
- BrowserCapabilitiesCompiler.cs
- CountAggregationOperator.cs
- Matrix3D.cs
- ObjectConverter.cs
- TheQuery.cs
- Group.cs
- TypeDescriptionProviderAttribute.cs
- MappedMetaModel.cs
- PolicyLevel.cs
- ExpressionStringBuilder.cs
- ConfigurationValues.cs
- ColorIndependentAnimationStorage.cs
- WindowsPrincipal.cs
- Effect.cs
- CodeExporter.cs
- ResolvedKeyFrameEntry.cs
- ServiceNameElementCollection.cs
- Quad.cs
- DrawTreeNodeEventArgs.cs
- PersonalizationAdministration.cs
- CommandBindingCollection.cs
- GeneralTransform3DTo2DTo3D.cs
- FloaterParagraph.cs
- AdRotatorDesigner.cs
- URLMembershipCondition.cs
- InputDevice.cs
- BoundPropertyEntry.cs
- GrammarBuilderRuleRef.cs
- CatalogPartChrome.cs
- Journal.cs
- XsdDateTime.cs
- ADConnectionHelper.cs
- DependencyObjectType.cs
- ToolboxSnapDragDropEventArgs.cs
- RequestCachingSection.cs
- XmlSchemaNotation.cs
- HwndSource.cs
- AttachedAnnotation.cs
- RelationshipConstraintValidator.cs
- XPathNavigatorKeyComparer.cs
- SecurityResources.cs
- HtmlPanelAdapter.cs
- VarRemapper.cs
- ExpressionBindingCollection.cs
- GridViewRowPresenterBase.cs
- Buffer.cs
- CodeMethodInvokeExpression.cs
- TextRangeAdaptor.cs
- Serializer.cs
- TabControl.cs
- RegexCode.cs
- TextAction.cs
- UIElement.cs
- BuildProviderAppliesToAttribute.cs