本文整理汇总了C#中System.Data.SqlClient.TdsParserStateObject.AddWarning方法的典型用法代码示例。如果您正苦于以下问题:C# TdsParserStateObject.AddWarning方法的具体用法?C# TdsParserStateObject.AddWarning怎么用?C# TdsParserStateObject.AddWarning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.TdsParserStateObject
的用法示例。
在下文中一共展示了TdsParserStateObject.AddWarning方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryRun
// Main parse loop for the top-level tds tokens, calls back into the I*Handler interfaces
internal bool TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, out bool dataReady)
{
Debug.Assert((SniContext.Undefined != stateObj.SniContext) && // SniContext must not be Undefined
((stateObj._attentionSent) || ((SniContext.Snix_Execute != stateObj.SniContext) && (SniContext.Snix_SendRows != stateObj.SniContext))), // SniContext should not be Execute or SendRows unless attention was sent (and, therefore, we are looking for an ACK)
String.Format("Unexpected SniContext on call to TryRun; SniContext={0}", stateObj.SniContext));
if (TdsParserState.Broken == State || TdsParserState.Closed == State)
{
dataReady = true;
return true; // Just in case this is called in a loop, expecting data to be returned.
}
dataReady = false;
do
{
// If there is data ready, but we didn't exit the loop, then something is wrong
Debug.Assert(!dataReady, "dataReady not expected - did we forget to skip the row?");
if (stateObj._internalTimeout)
{
runBehavior = RunBehavior.Attention;
}
if (TdsParserState.Broken == State || TdsParserState.Closed == State)
break; // jump out of the loop if the state is already broken or closed.
if (!stateObj._accumulateInfoEvents && (stateObj._pendingInfoEvents != null))
{
if (RunBehavior.Clean != (RunBehavior.Clean & runBehavior))
{
SqlConnection connection = null;
if (_connHandler != null)
connection = _connHandler.Connection; // SqlInternalConnection holds the user connection object as a weak ref
// We are omitting checks for error.Class in the code below (see processing of INFO) since we know (and assert) that error class
// error.Class < TdsEnums.MIN_ERROR_CLASS for info message.
// Also we know that TdsEnums.MIN_ERROR_CLASS<TdsEnums.MAX_USER_CORRECTABLE_ERROR_CLASS
if ((connection != null) && connection.FireInfoMessageEventOnUserErrors)
{
foreach (SqlError error in stateObj._pendingInfoEvents)
FireInfoMessageEvent(connection, stateObj, error);
}
else
foreach (SqlError error in stateObj._pendingInfoEvents)
stateObj.AddWarning(error);
}
stateObj._pendingInfoEvents = null;
}
byte token;
if (!stateObj.TryReadByte(out token))
{
return false;
}
if (!IsValidTdsToken(token))
{
Debug.Assert(false, String.Format((IFormatProvider)null, "unexpected token; token = {0,-2:X2}", token));
_state = TdsParserState.Broken;
_connHandler.BreakConnection();
throw SQL.ParsingError();
}
int tokenLength;
if (!TryGetTokenLength(token, stateObj, out tokenLength))
{
return false;
}
switch (token)
{
case TdsEnums.SQLERROR:
case TdsEnums.SQLINFO:
{
if (token == TdsEnums.SQLERROR)
{
stateObj._errorTokenReceived = true; // Keep track of the fact error token was received - for Done processing.
}
SqlError error;
if (!TryProcessError(token, stateObj, out error))
{
return false;
}
if (token == TdsEnums.SQLINFO && stateObj._accumulateInfoEvents)
{
Debug.Assert(error.Class < TdsEnums.MIN_ERROR_CLASS, "INFO with class > TdsEnums.MIN_ERROR_CLASS");
if (stateObj._pendingInfoEvents == null)
stateObj._pendingInfoEvents = new List<SqlError>();
stateObj._pendingInfoEvents.Add(error);
stateObj._syncOverAsync = true;
break;
}
if (RunBehavior.Clean != (RunBehavior.Clean & runBehavior))
{
// If FireInfoMessageEventOnUserErrors is true, we have to fire event without waiting.
//.........这里部分代码省略.........