IDataReader.RecordsAffected 属性

定义

通过执行 SQL 语句获取更改、插入或删除的行数。Gets the number of rows changed, inserted, or deleted by execution of the SQL statement.

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

属性值

Int32

已更改、插入或删除的行数;如果没有受影响的行或语句失败,则为 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.

注解

RecordsAffected 读取所有行并关闭之前,不会设置属性 IDataReaderThe RecordsAffected property is not set until all rows are read and you close the IDataReader.

IsClosedRecordsAffected 是在关闭 IDataReader 后可以调用的唯一属性。IsClosed and RecordsAffected are the only properties that you can call after the IDataReader is closed.

适用于