本文整理汇总了C#中System.Data.SqlClient.TdsParserStateObject.TryReadStringWithEncoding方法的典型用法代码示例。如果您正苦于以下问题:C# TdsParserStateObject.TryReadStringWithEncoding方法的具体用法?C# TdsParserStateObject.TryReadStringWithEncoding怎么用?C# TdsParserStateObject.TryReadStringWithEncoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.TdsParserStateObject
的用法示例。
在下文中一共展示了TdsParserStateObject.TryReadStringWithEncoding方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryReadSqlStringValue
private bool TryReadSqlStringValue(SqlBuffer value, byte type, int length, Encoding encoding, bool isPlp, TdsParserStateObject stateObj)
{
switch (type)
{
case TdsEnums.SQLCHAR:
case TdsEnums.SQLBIGCHAR:
case TdsEnums.SQLVARCHAR:
case TdsEnums.SQLBIGVARCHAR:
case TdsEnums.SQLTEXT:
// If bigvarchar(max), we only read the first chunk here,
// expecting the caller to read the rest
if (encoding == null)
{
// if hitting 7.0 server, encoding will be null in metadata for columns or return values since
// 7.0 has no support for multiple code pages in data - single code page support only
encoding = _defaultEncoding;
}
string stringValue;
if (!stateObj.TryReadStringWithEncoding(length, encoding, isPlp, out stringValue))
{
return false;
}
value.SetToString(stringValue);
break;
case TdsEnums.SQLNCHAR:
case TdsEnums.SQLNVARCHAR:
case TdsEnums.SQLNTEXT:
{
String s = null;
if (isPlp)
{
char[] cc = null;
if (!TryReadPlpUnicodeChars(ref cc, 0, length >> 1, stateObj, out length))
{
return false;
}
if (length > 0)
{
s = new String(cc, 0, length);
}
else
{
s = ADP.StrEmpty;
}
}
else
{
if (!stateObj.TryReadString(length >> 1, out s))
{
return false;
}
}
value.SetToString(s);
break;
}
default:
Debug.Assert(false, "Unknown tds type for SqlString!" + type.ToString(CultureInfo.InvariantCulture));
break;
}
return true;
}