String data getting truncated when fetching through sql datareader
I am using a datareader to fetch a table's record values through a stored proc. but while using datareader.getstring(2) to fetch the value of the particular column, the string returned is truncated ( rest of getstrings are returning complete values)开发者_运维技巧. Can anyone guide me in analyzing this?
The XML data row is truncated at 2,033 characters when you use the SqlDataReader object. To resolve this problem, use the ExecuteXmlReader method to read FOR XML queries. For additional information about how to use ExecuteXmlReader with SQL Server FOR XML queries https://support.microsoft.com/en-us/kb/310378 https://support.microsoft.com/en-us/kb/316701
Change your Db logic as following,
Declare @xmldata xml
set @xmldata =(<your select query>
FOR XML AUTO)
select @xmldata as returnXml
And read column returnXml from c# i.e. objReader[0]
精彩评论