SqlDataReader.RecordsAffected 屬性

定義

取得 Transact-SQL 陳述式的執行所變更、插入或刪除的資料列數目。Gets the number of rows changed, inserted, or deleted by execution of the Transact-SQL statement.

public:
 property int RecordsAffected { int get(); };
public int RecordsAffected { get; }
member this.RecordsAffected : int
Public ReadOnly Property RecordsAffected As Integer

屬性值

已變更、插入或刪除的資料列數目;如果沒有任何資料列受到影響或陳述式失敗,則為 0;如果是 SELECT 陳述式,則為 -1。The number of rows changed, inserted, or deleted; 0 if no rows were affected or the statement failed; and -1 for SELECT statements.

實作

備註

這個屬性的值為累計。The value of this property is cumulative. 例如,如果兩個記錄以批次模式插入,RecordsAffected 的值將會是兩個。For example, if two records are inserted in batch mode, the value of RecordsAffected will be two.

IsClosedRecordsAffected 是在關閉 SqlDataReader 之後,您可以呼叫的唯一屬性。IsClosed and RecordsAffected are the only properties that you can call after the SqlDataReader is closed.

適用於

另請參閱