当前位置: 首页>>代码示例>>C#>>正文


C# SqlCommand.OnStatementCompleted方法代码示例

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


在下文中一共展示了SqlCommand.OnStatementCompleted方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TryProcessDone

        private bool TryProcessDone(SqlCommand cmd, SqlDataReader reader, ref RunBehavior run, TdsParserStateObject stateObj)
        {
            ushort curCmd;
            ushort status;
            int count;

            // Can't retry TryProcessDone
            stateObj._syncOverAsync = true;

            // status
            // command
            // rowcount (valid only if DONE_COUNT bit is set)

            if (!stateObj.TryReadUInt16(out status))
            {
                return false;
            }
            if (!stateObj.TryReadUInt16(out curCmd))
            {
                return false;
            }

            long longCount;
            if (!stateObj.TryReadInt64(out longCount))
            {
                return false;
            }
            count = (int)longCount;

            // We get a done token with the attention bit set
            if (TdsEnums.DONE_ATTN == (status & TdsEnums.DONE_ATTN))
            {
                Debug.Assert(TdsEnums.DONE_MORE != (status & TdsEnums.DONE_MORE), "Not expecting DONE_MORE when receiving DONE_ATTN");
                Debug.Assert(stateObj._attentionSent, "Received attention done without sending one!");
                stateObj._attentionReceived = true;
                Debug.Assert(stateObj._inBytesUsed == stateObj._inBytesRead && stateObj._inBytesPacket == 0, "DONE_ATTN received with more data left on wire");
            }
            if ((null != cmd) && (TdsEnums.DONE_COUNT == (status & TdsEnums.DONE_COUNT)))
            {
                if (curCmd != TdsEnums.SELECT)
                {
                    cmd.InternalRecordsAffected = count;
                }
                // Skip the bogus DONE counts sent by the server
                if (stateObj._receivedColMetaData || (curCmd != TdsEnums.SELECT))
                {
                    cmd.OnStatementCompleted(count);
                }
            }

            stateObj._receivedColMetaData = false;

            // Surface exception for DONE_ERROR in the case we did not receive an error token
            // in the stream, but an error occurred.  In these cases, we throw a general server error.  The
            // situations where this can occur are: an invalid buffer received from client, login error
            // and the server refused our connection, and the case where we are trying to log in but
            // the server has reached its max connection limit.  Bottom line, we need to throw general
            // error in the cases where we did not receive a error token along with the DONE_ERROR.
            if ((TdsEnums.DONE_ERROR == (TdsEnums.DONE_ERROR & status)) && stateObj.ErrorCount == 0 &&
                  stateObj._errorTokenReceived == false && (RunBehavior.Clean != (RunBehavior.Clean & run)))
            {
                stateObj.AddError(new SqlError(0, 0, TdsEnums.MIN_ERROR_CLASS, _server, SQLMessage.SevereError(), "", 0));

                if (null != reader)
                {
                    if (!reader.IsInitialized)
                    {
                        run = RunBehavior.UntilDone;
                    }
                }
            }

            // Similar to above, only with a more severe error.  In this case, if we received
            // the done_srverror, this exception will be added to the collection regardless.
            // The server will always break the connection in this case.
            if ((TdsEnums.DONE_SRVERROR == (TdsEnums.DONE_SRVERROR & status)) && (RunBehavior.Clean != (RunBehavior.Clean & run)))
            {
                stateObj.AddError(new SqlError(0, 0, TdsEnums.FATAL_ERROR_CLASS, _server, SQLMessage.SevereError(), "", 0));

                if (null != reader)
                {
                    if (!reader.IsInitialized)
                    {
                        run = RunBehavior.UntilDone;
                    }
                }
            }

            ProcessSqlStatistics(curCmd, status, count);

            // stop if the DONE_MORE bit isn't set (see above for attention handling)
            if (TdsEnums.DONE_MORE != (status & TdsEnums.DONE_MORE))
            {
                stateObj._errorTokenReceived = false;
                if (stateObj._inBytesUsed >= stateObj._inBytesRead)
                {
                    stateObj._pendingData = false;
                }
            }

//.........这里部分代码省略.........
开发者ID:nnyamhon,项目名称:corefx,代码行数:101,代码来源:TdsParser.cs

示例2: ProcessDone

 private void ProcessDone(SqlCommand cmd, SqlDataReader reader, ref RunBehavior run, TdsParserStateObject stateObj)
 {
     int num2;
     ushort status = stateObj.ReadUInt16();
     ushort curCmd = stateObj.ReadUInt16();
     if (this._isYukon)
     {
         num2 = (int) stateObj.ReadInt64();
     }
     else
     {
         num2 = stateObj.ReadInt32();
         if (((this._state == TdsParserState.OpenNotLoggedIn) && (stateObj._inBytesRead > stateObj._inBytesUsed)) && (stateObj.PeekByte() == 0))
         {
             num2 = stateObj.ReadInt32();
         }
     }
     if (0x20 == (status & 0x20))
     {
         stateObj._attentionReceived = true;
     }
     if ((cmd != null) && (0x10 == (status & 0x10)))
     {
         if (curCmd != 0xc1)
         {
             cmd.InternalRecordsAffected = num2;
         }
         if (stateObj._receivedColMetaData || (curCmd != 0xc1))
         {
             cmd.OnStatementCompleted(num2);
         }
     }
     stateObj._receivedColMetaData = false;
     if (((2 == (2 & status)) && (this._errors == null)) && (!stateObj._errorTokenReceived && (RunBehavior.Clean != (RunBehavior.Clean & run))))
     {
         this.Errors.Add(new SqlError(0, 0, 11, this._server, SQLMessage.SevereError(), "", 0));
         if ((reader != null) && !reader.IsInitialized)
         {
             run = RunBehavior.UntilDone;
         }
     }
     if ((0x100 == (0x100 & status)) && (RunBehavior.Clean != (RunBehavior.Clean & run)))
     {
         this.Errors.Add(new SqlError(0, 0, 20, this._server, SQLMessage.SevereError(), "", 0));
         if ((reader != null) && !reader.IsInitialized)
         {
             run = RunBehavior.UntilDone;
         }
     }
     this.ProcessSqlStatistics(curCmd, status, num2);
     if (1 != (status & 1))
     {
         stateObj._errorTokenReceived = false;
         if (stateObj._inBytesUsed >= stateObj._inBytesRead)
         {
             stateObj._pendingData = false;
         }
     }
     if (!stateObj._pendingData && stateObj._hasOpenResult)
     {
         stateObj.DecrementOpenResultCount();
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:63,代码来源:TdsParser.cs


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