• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# SqlClient.SqlErrorCollection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Data.SqlClient.SqlErrorCollection的典型用法代码示例。如果您正苦于以下问题:C# SqlErrorCollection类的具体用法?C# SqlErrorCollection怎么用?C# SqlErrorCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SqlErrorCollection类属于System.Data.SqlClient命名空间,在下文中一共展示了SqlErrorCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CreateException

        static internal SqlException CreateException(SqlErrorCollection errorCollection, string serverVersion, Guid conId, Exception innerException = null) {
            Debug.Assert(null != errorCollection && errorCollection.Count > 0, "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);
            }

            if (innerException == null && errorCollection[0].Win32ErrorCode != 0 && errorCollection[0].Win32ErrorCode != -1) {
                innerException = new Win32Exception(errorCollection[0].Win32ErrorCode);
            }

            SqlException exception = new SqlException(message.ToString(), /*errorCollection, */innerException/*, conId*/);

            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;
        }
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:30,代码来源:SqlException.cs


示例2: SqlMessageEventArgs

 internal SqlMessageEventArgs(SqlErrorCollection errors, string message, string source, object context)
 {
     mErrors = errors;
     mMessage = message;
     mSource = source;
     mContext = context;
 }
开发者ID:afj88,项目名称:DBBranchManager,代码行数:7,代码来源:SqlMessageEventArgs.cs


示例3: SqlException

		internal SqlException (string message, Exception inner, SqlError sqlError)
			: base (message == null ? DEF_MESSAGE : message, inner)
		{
			HResult = -2146232060;
			errors = new SqlErrorCollection ();
			if (sqlError != null)
				errors.Add (sqlError);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:SqlException.cs


示例4: SqlException

 // 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;
     foreach (SerializationEntry siEntry in si) {
         if ("ClientConnectionId" == siEntry.Name) {
             _clientConnectionId = (Guid)siEntry.Value;
             break;
         }
     }
         
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:12,代码来源:SqlException.cs


示例5: CreateException

        private SqlException CreateException(SqlErrorCollection errorCollection)
        {
            // Create instance via reflection...
            var ctor = typeof(SqlException).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance)[0];
            SqlException sqlException = ctor.Invoke(
                new object[]
            {
                // With message and error collection...
                this.errorMessage,
                errorCollection,
                null,
                Guid.NewGuid()
            }) as SqlException;

            return sqlException;
        }
开发者ID:G-Rad,项目名称:reliable-sql,代码行数:16,代码来源:SqlExceptionBuilder.cs


示例6: CreateLocalDBException

 private static SqlException CreateLocalDBException(string errorMessage, string instance = null, int localDbError = 0, int sniError = 0)
 {
     SqlErrorCollection errorCollection = new SqlErrorCollection();
     int infoNumber = (localDbError == 0) ? sniError : localDbError;
     if (sniError != 0)
     {
         string name = string.Format(null, "SNI_ERROR_{0}", new object[] { sniError });
         errorMessage = string.Format(null, "{0} (error: {1} - {2})", new object[] { errorMessage, sniError, Res.GetString(name) });
     }
     errorCollection.Add(new SqlError(infoNumber, 0, 20, instance, errorMessage, null, 0));
     if (localDbError != 0)
     {
         errorCollection.Add(new SqlError(infoNumber, 0, 20, instance, GetLocalDBMessage(localDbError), null, 0));
     }
     SqlException exception = SqlException.CreateException(errorCollection, null);
     exception._doNotReconnect = true;
     return exception;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:18,代码来源:LocalDBAPI.cs


示例7: ProcessMessages

        protected SqlException ProcessMessages(bool ignoreWarnings)
        {
            SqlException result = null;
            SqlErrorCollection temp = null;  // temp variable to store that which is being thrown - so that local copies can be deleted

            if (null != _errors)
            {
                Debug.Assert(0 != _errors.Count, "empty error collection?"); // must be something in the collection

                {
                    if (null != _warnings)
                    {
                        // When we throw an exception we place all the warnings that
                        // occurred at the end of the collection - after all the errors.
                        // That way the user can see all the errors AND warnings that
                        // occurred for the exception.
                        foreach (SqlError warning in _warnings)
                        {
                            _errors.Add(warning);
                        }
                    }
                    temp = _errors;
                }

                _errors = null;
                _warnings = null;
            }
            else
            {
                Debug.Assert(null == _warnings || 0 != _warnings.Count, "empty warning collection?");// must be something in the collection

                if (!ignoreWarnings)
                {
                    temp = _warnings;
                }
                _warnings = null;
            }

            if (null != temp)
            {
                result = SqlException.CreateException(temp, ServerVersion);
            }
            return result;
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:44,代码来源:SmiEventSink_Default.cs


示例8: AddSqlErrorToCollection

 private bool AddSqlErrorToCollection(ref SqlErrorCollection temp, ref SqlErrorCollection InputCollection)
 {
     if (InputCollection == null)
     {
         return false;
     }
     bool flag = false;
     if (temp == null)
     {
         temp = new SqlErrorCollection();
     }
     for (int i = 0; i < InputCollection.Count; i++)
     {
         SqlError error = InputCollection[i];
         temp.Add(error);
         if (error.Class >= 20)
         {
             flag = true;
         }
     }
     InputCollection = null;
     return (flag && (TdsParserState.Closed != this._state));
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:23,代码来源:TdsParser.cs


示例9: CreateException

 internal static SqlException CreateException(SqlErrorCollection errorCollection, string serverVersion)
 {
     StringBuilder builder = new StringBuilder();
     for (int i = 0; i < errorCollection.Count; i++)
     {
         if (i > 0)
         {
             builder.Append(Environment.NewLine);
         }
         builder.Append(errorCollection[i].Message);
     }
     SqlException exception = new SqlException(builder.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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:23,代码来源:SqlException.cs


示例10: AddErrorsToCollection

 private void AddErrorsToCollection(SqlErrorCollection inCollection, ref SqlErrorCollection collectionToAddTo, ref bool broken)
 {
     if (inCollection != null)
     {
         foreach (SqlError error in inCollection)
         {
             collectionToAddTo.Add(error);
             broken |= (error.Class >= TdsEnums.FATAL_ERROR_CLASS);
         }
     }
 }
开发者ID:nnyamhon,项目名称:corefx,代码行数:11,代码来源:TdsParserStateObject.cs


示例11: GetFullErrorAndWarningCollection

        /// <summary>
        /// Gets the full list of errors and warnings (including the pre-attention ones), then wipes all error and warning lists
        /// </summary>
        /// <param name="broken">If true, the connection should be broken</param>
        /// <returns>An array containing all of the errors and warnings</returns>
        internal SqlErrorCollection GetFullErrorAndWarningCollection(out bool broken)
        {
            SqlErrorCollection allErrors = new SqlErrorCollection();
            broken = false;

            lock (_errorAndWarningsLock)
            {
                _hasErrorOrWarning = false;

                // Merge all error lists, then reset them
                AddErrorsToCollection(_errors, ref allErrors, ref broken);
                AddErrorsToCollection(_warnings, ref allErrors, ref broken);
                _errors = null;
                _warnings = null;

                // We also process the pre-attention error lists here since, if we are here and they are populated, then an error occured while sending attention so we should show the errors now (otherwise they'd be lost)
                AddErrorsToCollection(_preAttentionErrors, ref allErrors, ref broken);
                AddErrorsToCollection(_preAttentionWarnings, ref allErrors, ref broken);
                _preAttentionErrors = null;
                _preAttentionWarnings = null;
            }

            return allErrors;
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:29,代码来源:TdsParserStateObject.cs


示例12: CreateException

 static internal SqlException CreateException(SqlErrorCollection errorCollection, string serverVersion) {
     return CreateException(errorCollection, serverVersion, Guid.Empty);
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:3,代码来源:SqlException.cs


示例13: AddError

 private static void AddError(SqlErrorCollection collection, Error infoNumber, byte errorState, byte errorClass, string server, string errorMessage, string procedure, int lineNumber)
 {
     var error = Ctor.New<SqlError>((int)infoNumber, errorState, errorClass, server, errorMessage, procedure, lineNumber);
     var add = typeof(SqlErrorCollection).GetMethod("Add", BindingFlags.Instance | BindingFlags.NonPublic);
     add.Invoke(collection, new object[] { error });
 }
开发者ID:Corniel,项目名称:Allergic,代码行数:6,代码来源:SqlExceptions.cs


示例14: FireInfoMessageEvent

        // Fires a single InfoMessageEvent
        private void FireInfoMessageEvent(SqlConnection connection, TdsParserStateObject stateObj, SqlError error)
        {
            string serverVersion = null;

            Debug.Assert(connection != null && _connHandler.Connection == connection);

            if (_state == TdsParserState.OpenLoggedIn)
            {
                serverVersion = _connHandler.ServerVersion;
            }

            SqlErrorCollection sqlErs = new SqlErrorCollection();

            sqlErs.Add(error);

            SqlException exc = SqlException.CreateException(sqlErs, serverVersion, _connHandler);

            bool notified;
            connection.OnInfoMessage(new SqlInfoMessageEventArgs(exc), out notified);
            if (notified)
            {
                // observable side-effects, no retry
                stateObj._syncOverAsync = true;
            }
            return;
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:27,代码来源:TdsParser.cs


示例15: CreateException

		static internal SqlException CreateException(SqlErrorCollection errorCollection, string serverVersion, Guid conId, Exception innerException = null)
		{
			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:4,代码来源:SqlException.platformnotsupported.cs


示例16: OnSqlWarning

		protected internal sealed override void OnSqlWarning(SQLWarning warning)
		{
			SqlErrorCollection col = new SqlErrorCollection(warning, this);
			OnSqlInfoMessage(new SqlInfoMessageEventArgs(col));
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:5,代码来源:SqlConnection.cs


示例17: GetFedAuthToken

        /// <summary>
        /// Get the Federated Authentication Token.
        /// </summary>
        /// <param name="fedAuthInfo">Information obtained from server as Federated Authentication Info.</param>
        /// <returns>SqlFedAuthToken</returns>
        internal SqlFedAuthToken GetFedAuthToken(SqlFedAuthInfo fedAuthInfo) {

            Debug.Assert(fedAuthInfo != null, "fedAuthInfo should not be null.");

            // No:of milliseconds to sleep for the inital back off.
            int sleepInterval = 100;

            // No:of attempts, for tracing purposes, if we underwent retries.
            int numberOfAttempts = 0;

            // Object that will be returned to the caller, containing all required data about the token.
            SqlFedAuthToken fedAuthToken = new SqlFedAuthToken();

            // Username to use in error messages.
            string username = null;

            while (true) {
                numberOfAttempts++;
                try {
                    if (ConnectionOptions.Authentication == SqlAuthenticationMethod.ActiveDirectoryIntegrated) {
                        username = TdsEnums.NTAUTHORITYANONYMOUSLOGON;
                        fedAuthToken.accessToken = ADALNativeWrapper.ADALGetAccessTokenForWindowsIntegrated(fedAuthInfo.stsurl,
                                                                                                                fedAuthInfo.spn,
                                                                                                                _clientConnectionId, ActiveDirectoryAuthentication.AdoClientId,
                                                                                                                ref fedAuthToken.expirationFileTime);
                    }
                    else if (_credential != null) {
                        username = _credential.UserId;
                        fedAuthToken.accessToken = ADALNativeWrapper.ADALGetAccessToken(_credential.UserId,
                                                                                            _credential.Password,
                                                                                            fedAuthInfo.stsurl,
                                                                                            fedAuthInfo.spn,
                                                                                            _clientConnectionId,
                                                                                            ActiveDirectoryAuthentication.AdoClientId,
                                                                                            ref fedAuthToken.expirationFileTime);
                    }
                    else {
                        username = ConnectionOptions.UserID;
                        fedAuthToken.accessToken = ADALNativeWrapper.ADALGetAccessToken(ConnectionOptions.UserID,
                                                                                            ConnectionOptions.Password,
                                                                                            fedAuthInfo.stsurl,
                                                                                            fedAuthInfo.spn,
                                                                                            _clientConnectionId,
                                                                                            ActiveDirectoryAuthentication.AdoClientId,
                                                                                            ref fedAuthToken.expirationFileTime);
                    }

                    Debug.Assert(fedAuthToken.accessToken != null, "AccessToken should not be null.");
#if DEBUG
                    if (_forceAdalRetry) {
                        // 3399614468 is 0xCAA20004L just for testing.
                        throw new AdalException("Force retry in GetFedAuthToken", ActiveDirectoryAuthentication.GetAccessTokenTansisentError, 3399614468, 6);
                    }
#endif
                    // Break out of the retry loop in successful case.
                    break;
                }
                catch (AdalException adalException) {

                    uint errorCategory = adalException.GetCategory();

                    if (ActiveDirectoryAuthentication.GetAccessTokenTansisentError != errorCategory
                        || _timeout.IsExpired
                        || _timeout.MillisecondsRemaining <= sleepInterval) {

                        string errorStatus = adalException.GetStatus().ToString("X");

                        Bid.Trace("<sc.SqlInternalConnectionTds.GetFedAuthToken.ADALException category:> %d#  <error:> %s#\n", (int)errorCategory, errorStatus);

                        // Error[0]
                        SqlErrorCollection sqlErs = new SqlErrorCollection();
                        sqlErs.Add(new SqlError(0, (byte)0x00, (byte)TdsEnums.MIN_ERROR_CLASS, ConnectionOptions.DataSource, Res.GetString(Res.SQL_ADALFailure, username, ConnectionOptions.Authentication.ToString("G")), ActiveDirectoryAuthentication.AdalGetAccessTokenFunctionName, 0));

                        // Error[1]
                        string errorMessage1 = Res.GetString(Res.SQL_ADALInnerException, errorStatus, adalException.GetState());
                        sqlErs.Add(new SqlError(0, (byte)0x00, (byte)TdsEnums.MIN_ERROR_CLASS, ConnectionOptions.DataSource, errorMessage1, ActiveDirectoryAuthentication.AdalGetAccessTokenFunctionName, 0));

                        // Error[2]
                        if (!string.IsNullOrEmpty(adalException.Message)) {
                            sqlErs.Add(new SqlError(0, (byte)0x00, (byte)TdsEnums.MIN_ERROR_CLASS, ConnectionOptions.DataSource, adalException.Message, ActiveDirectoryAuthentication.AdalGetAccessTokenFunctionName, 0));
                        }
                        SqlException exc = SqlException.CreateException(sqlErs, "", this);
                        throw exc;
                    }

                    Bid.Trace("<sc.SqlInternalConnectionTds.GetFedAuthToken|ADV> %d#, sleeping %d{Milliseconds}\n", ObjectID, sleepInterval);
                    Bid.Trace("<sc.SqlInternalConnectionTds.GetFedAuthToken|ADV> %d#, remaining %d{Milliseconds}\n", ObjectID, _timeout.MillisecondsRemaining);

                    Thread.Sleep(sleepInterval);
                    sleepInterval *= 2;
                }
            }

            Debug.Assert(fedAuthToken != null, "fedAuthToken should not be null.");
            Debug.Assert(fedAuthToken.accessToken != null && fedAuthToken.accessToken.Length > 0, "fedAuthToken.accessToken should not be null or empty.");
//.........这里部分代码省略.........
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:101,代码来源:SqlInternalConnectionTds.cs


示例18: GetErrors

 internal SqlException GetErrors(int commandIndex)
 {
     SqlException exception = null;
     int num3 = this._SqlRPCBatchArray[commandIndex].errorsIndexEnd - this._SqlRPCBatchArray[commandIndex].errorsIndexStart;
     if (0 >= num3)
     {
         return exception;
     }
     SqlErrorCollection errorCollection = new SqlErrorCollection();
     for (int i = this._SqlRPCBatchArray[commandIndex].errorsIndexStart; i < this._SqlRPCBatchArray[commandIndex].errorsIndexEnd; i++)
     {
         errorCollection.Add(this._SqlRPCBatchArray[commandIndex].errors[i]);
     }
     for (int j = this._SqlRPCBatchArray[commandIndex].warningsIndexStart; j < this._SqlRPCBatchArray[commandIndex].warningsIndexEnd; j++)
     {
         errorCollection.Add(this._SqlRPCBatchArray[commandIndex].warnings[j]);
     }
     return SqlException.CreateException(errorCollection, this.Connection.ServerVersion);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:19,代码来源:SqlCommand.cs


示例19: ExecuteEventArgs

 public ExecuteEventArgs(SqlErrorCollection sqlInfo)
 {
     this.succeeded = true;
     this.sqlInfo = sqlInfo;
 }
开发者ID:KjartanThor,项目名称:CustomActivities,代码行数:5,代码来源:ExecuteEventArgs.cs


示例20: CannotCompleteDelegatedTransactionWithOpenResults

 internal static Exception CannotCompleteDelegatedTransactionWithOpenResults()
 {
     SqlErrorCollection errorCollection = new SqlErrorCollection();
     errorCollection.Add(new SqlError(-2, 0, 11, null, Res.GetString("ADP_OpenReaderExists"), "", 0));
     return SqlException.CreateException(errorCollection, null);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:6,代码来源:SQL.cs



注:本文中的System.Data.SqlClient.SqlErrorCollection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SqlClient.SqlException类代码示例发布时间:2022-05-26
下一篇:
C# SqlClient.SqlDependency类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap