dotConnect for Adobe Commerce Documentation
Devart.Data Namespace / SqlShimDataReader Class / RecordsAffected Property
Example

In This Topic
    RecordsAffected Property (SqlShimDataReader)
    In This Topic
    Gets the number of rows changed, inserted, or deleted by execution of the SQL statement.
    Syntax
    'Declaration
     
    Public Overrides ReadOnly Property RecordsAffected As Integer
    public override int RecordsAffected {get;}

    Property Value

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

    IsClosed and RecordsAffected are the only properties that you can call after the SqlShimDataReader is closed.

    Example
    This sample shows how to find out how many rows have been affected during last query. You can do it even if the SqlShimDataReader has been closed.
    public void ProcessReader (MagentoDataReader adobe commerceReader)
    {
      if (!adobe commerceReader.IsClosed)
      {
        while (adobe commerceReader.Read())
        {
          for (int i=0;i<adobe commerceReader.FieldCount;i++)
          {
            Console.Write("\t"+adobe commerceReader[i]);
          }
          Console.WriteLine();
        }
      }
      else
      {
        Console.WriteLine("The DataReader is closed. Rows affected in last action: "+adobe commerceReader.RecordsAffected);
      }
    }
    Public Sub ProcessReader(ByVal adobe commerceReader As MagentoDataReader)
      If Not adobe commerceReader.IsClosed Then
        Dim i As Integer
        While adobe commerceReader.Read()
          For i = 0 To adobe commerceReader.FieldCount - 1
            Console.Write(" " & adobe commerceReader(i))
          Next i
          Console.WriteLine()
        End While
      Else
        Console.WriteLine("The DataReader is closed. Rows affected in last action: " & adobe commerceReader.RecordsAffected)
      End If
    End Sub
    See Also