SqlDataReader.FieldCount 屬性

定義

取得目前資料列中的資料行數目。

public:
 virtual property int FieldCount { int get(); };
public:
 property int FieldCount { int get(); };
public override int FieldCount { get; }
public int FieldCount { get; }
member this.FieldCount : int
Public Overrides ReadOnly Property FieldCount As Integer
Public ReadOnly Property FieldCount As Integer

屬性值

當未置於有效資料錄集 (Recordset) 時,則為 0,否則為目前資料列中的資料行數目。 預設值為 -1。

實作

例外狀況

目前沒有連接至 SQL Server 的執行個體。

備註

執行本質上的查詢不會傳回數據列 (,例如 DELETE 查詢) 設定 FieldCount 為 0。 不過, 這不應該與傳回 0 個資料列 (的查詢混淆,例如 SELECT * FROM 數據表 WHERE 1 = 2) 在此情況下 FieldCount 會傳回數據表中的數據行數目,包括隱藏字段。 使用 VisibleFieldCount 以排除隱藏欄位。

適用於

另請參閱