3

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?

1
  • 6
    You need to show us the stored proc code, maybe the values is returned as varchar(x) x smaller than the length of the actual column length? Commented Dec 16, 2010 at 11:44

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

0

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]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.