SqlDataReader.GetTextReader(Int32) 方法

定義

擷取 Char、NChar、 NText、 NVarChar、 文字、 varChar 及 Variant 資料型別做為TextReaderRetrieves Char, NChar, NText, NVarChar, text, varChar, and Variant data types as a TextReader.

public:
 override System::IO::TextReader ^ GetTextReader(int i);
public override System.IO.TextReader GetTextReader (int i);
override this.GetTextReader : int -> System.IO.TextReader
Public Overrides Function GetTextReader (i As Integer) As TextReader

參數

i
Int32

要擷取的資料行。The column to be retrieved.

傳回

已傳回的物件。The returned object.

例外狀況

在資料擷取期間,連線中斷或關閉。The connection drops or is closed during the data retrieval.

SqlDataReader在資料擷取期間已關閉。The SqlDataReader is closed during the data retrieval.

沒有可供讀取的資料 (例如,第一個 Read() 沒有被呼叫,或傳回 false)。There is no data ready to be read (for example, the first Read() hasn't been called, or returned false).

嘗試在循序模式下讀取先前讀取的資料行。Tried to read a previously-read column in sequential mode.

有進行中的非同步作業。There was an asynchronous operation in progress. 當在循序模式中執行時,此適用於所有 Get* 方法,因為在讀取資料流時可能會呼叫它們。This applies to all Get* methods when running in sequential mode, as they could be called while reading a stream.

嘗試讀取不存在的資料行。Trying to read a column that does not exist.

傳回的型別不是下列型別:The returned type was not one of the types below:

- 字元- char

- Nchar- nchar

- ntext- ntext

- Nvarchar- nvarchar

- 文字- text

- varchar- varchar

備註

TextReader 引發的 SqlException 例外狀況會擲回 IOException 例外狀況;檢查 SqlException的內部例外狀況。SqlException exceptions raised from TextReader are thrown as IOException exceptions; check the inner exception for the SqlException.

Null 值會以空的(零位元組) TextReader傳回。Null values will be returned as an empty (zero bytes) TextReader.

SequentialAccess 生效時,GetChars 將會引發 InvalidOperationException 的例外狀況,並在 GetTextReader 傳回的物件上使用。GetChars will raise an InvalidOperationException exception when used on an object returned by GetTextReader when SequentialAccess is in effect.

當連接屬性 ContextConnection=true時,GetTextReader 僅支援連續(SequentialAccess)和非連續(Default)存取的同步資料抓取。When the connection property ContextConnection=true, GetTextReader only supports synchronous data retrieval for both sequential (SequentialAccess) and non-sequential (Default) access.

如需詳細資訊,請參閱SqlClient 串流支援For more information, see SqlClient Streaming Support.

適用於