Share via


SqlDataReader.GetXmlReader(Int32) Method

Definition

Retrieves data of type XML as an XmlReader.

public:
 virtual System::Xml::XmlReader ^ GetXmlReader(int i);
public virtual System.Xml.XmlReader GetXmlReader(int i);
abstract member GetXmlReader : int -> System.Xml.XmlReader
override this.GetXmlReader : int -> System.Xml.XmlReader
Public Overridable Function GetXmlReader (i As Integer) As XmlReader

Parameters

i
Int32

The value of the specified column.

Returns

The returned object.

Exceptions

Trying to read a column that does not exist.

The returned type was not xml.

Remarks

The XmlReader object returned by GetXmlReader(Int32) does not support asynchronous operations. If you require asynchronous operations on an XmlReader, cast the XML column to an NVARCHAR(MAX) on the server and use GetTextReader(Int32) with Create(TextReader). SqlException exceptions raised from XmlReader are thrown as XmlException exceptions; check the inner exception for the SqlException. GetChars(Int32, Int64, Char[], Int32, Int32) will raise an InvalidOperationException exception when used on an object returned by GetXmlReader(Int32) when SequentialAccess is in effect.

For more information, see SqlClient Streaming Support.

Applies to