DB2DataReader.GetChars 方法
將字元串流從指定的直欄偏移讀取至緩衝區作為陣列,從給定的緩衝區偏移開始。
- 名稱空間:
IBM.Data.DB2- 組件:
IBM.Data.DB2(在IBM.Data.DB2.dll中)
語法
idataIndexbufferbufferIndexlengthidataIndexbufferbufferIndexlengthidataIndexbufferbufferIndexlengthidataIndexbufferbufferIndexlength
[Visual Basic]
Public Function GetChars( _
ByVal As Integer, _
ByVal As Long, _
ByVal () As Char, _
ByVal As Integer, _
ByVal As Integer _
) As Long
[C#]
public long GetChars(
int ,
long ,
char[] ,
int ,
int
);
[C++]
public: __int64 GetChars(
int ,
__int64 ,
__wchar_t __gc[],
int ,
int
);
[JScript]
public function GetChars(
: int,
: long,
: Char[],
: int,
: int
) : long;
參數
- i
- 從零開始的直欄序數。
- dataIndex
- 要開始讀取作業之列內的索引。
- buffer
- 要將資料複製到其中的緩衝區。
- bufferIndex
- buffer 將在其中開始寫入作業的索引。
- length
- 要讀取的字元數。
回覆值
實際讀取的字元數。
異常狀況
| 異常狀況類型 | 條件 |
|---|---|
| DB2Exception | 無效的轉換。 |
備註
GetChars 會傳回欄位中可用的字元數。 在大部分情況下,這是欄位的確切長度。 不過,如果已使用 GetChars 來從欄位取得字元,則傳回的數字可能小於欄位的真實長度。 例如,如果 DB2®DataReader 將 CLOB 讀取到緩衝區中,則可能是這種情況。 如需相關資訊,請參閱 Microsoft ® .NET Framework SDK 文件中 System.Data.CommandBehavior 的 SequentialAccess 設定。
如果您傳遞的緩衝區是空值。 GetChars 會傳回欄位的長度 (以字元為單位)。
不執行任何轉換。 要擷取的資料必須是下列其中一種類型:
- DB2Type.Char
- DB2Type.VarChar
- DB2Type.LongVarChar
- DB2Type.Clob
- DB2Type.Graphic
- DB2Type.VarGraphic
- DB2Type.LongVarGraphic
- DB2Type.DbClob
下表說明傳回物件資料類型與資料伺服器資料類型之間的對映。
| DB2類型資料類型 | Db2® 資料類型 | Informix® 資料類型 |
|---|---|---|
| 字元 | CHAR | CHAR |
| VarChar | VARCHAR | VARCHAR |
| LongVarChar | LONG VARCHAR | LVARCHAR |
| CLOB | CLOB | CLOB 及 TEXT |
| 圖形 | GRAPHIC | |
| VARGRAPHIC | VARGRAPHIC | |
| LongVarGraphic | LONG VARGRAPHIC | |
| DBCLOB | DBCLOB |