Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security
updates, and technical support.

[ Download Microsoft Edge ](https://go.microsoft.com/fwlink/p/?LinkID=2092881
) [ More info about Internet Explorer and Microsoft Edge
](https://learn.microsoft.com/en-us/lifecycle/faq/internet-explorer-microsoft-
edge)

Table of contents  Exit focus mode

Language

  *   *   *   * 

Read in English  Save  [ ](https://github.com/dotnet/dotnet-api-
docs/blob/main/xml/System.Data.SqlClient/SqlDataReader.xml "Edit This
Document")

Table of contents  Read in English  Save  [ Edit
](https://github.com/dotnet/dotnet-api-
docs/blob/main/xml/System.Data.SqlClient/SqlDataReader.xml "Edit This
Document") Print

Twitter  LinkedIn  Facebook  Email

Table of contents

#  Sql  Data  Reader.  Records  Affected Property

  * Reference 

Feedback

##

##  Definition

Namespace:

     [ System.Data.SqlClient ](system.data.sqlclient?view=dotnet-plat-ext-8.0)

Assembly:

     System.Data.SqlClient.dll 

Assembly:

     System.Data.dll 

Package:

     System.Data.SqlClient v4.8.6 

Important

Some information relates to prerelease product that may be substantially
modified before itâs released. Microsoft makes no warranties, express or
implied, with respect to the information provided here.

Gets the number of rows changed, inserted, or deleted by execution of the
Transact-SQL statement.

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

####  Property Value

[ Int32 ](system.int32?view=dotnet-plat-ext-8.0)

The number of rows changed, inserted, or deleted; 0 if no rows were affected
or the statement failed; and -1 for SELECT statements.

####  Implements

[ RecordsAffected ](system.data.idatareader.recordsaffected?view=dotnet-plat-
ext-8.0#system-data-idatareader-recordsaffected)

##  Remarks

The value of this property is cumulative. For example, if two records are
inserted in batch mode, the value of ` RecordsAffected ` will be two.

[ IsClosed ](system.data.sqlclient.sqldatareader.isclosed?view=dotnet-plat-
ext-8.0) and [ RecordsAffected
](system.data.sqlclient.sqldatareader.recordsaffected?view=dotnet-plat-
ext-8.0) are the only properties that you can call after the [ SqlDataReader
](system.data.sqlclient.sqldatareader?view=dotnet-plat-ext-8.0) is closed.

##  Applies to

##  See also

  * [ SQL Server Connection Pooling (ADO.NET) ](/en-us/dotnet/framework/data/adonet/sql-server-connection-pooling)
  * [ DataAdapters and DataReaders (ADO.NET) ](/en-us/dotnet/framework/data/adonet/dataadapters-and-datareaders)
  * [ SQL Server and ADO.NET ](/en-us/dotnet/framework/data/adonet/sql/)
  * [ ADO.NET Overview ](/en-us/dotnet/framework/data/adonet/ado-net-overview)

Collaborate with us on GitHub

The source for this content can be found on GitHub, where you can also create
and review issues and pull requests. For more information, see [ our
contributor guide ](https://learn.microsoft.com/contribute/content/dotnet/api-
documentation) .

![](https://learn.microsoft.com/media/logos/logo_net.svg)
![](https://learn.microsoft.com/media/logos/logo_net.svg)

.NET

[ Open a documentation issue  ]() [ Provide product feedback
](https://aka.ms/feedback/report?space=61)

##  Feedback

Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the
feedback mechanism for content and replacing it with a new feedback system.
For more information see: [ https://aka.ms/ContentUserFeedback
](https://aka.ms/ContentUserFeedback) .

Submit and view feedback for

[ This product  ](https://aka.ms/f