Search code examples
c#mysql.netsqlexecutenonquery

Get affected rows on ExecuteNonQuery


I am currently working on a C# project and I am running an insert query which also does a select at the same time, e.g.:

INSERT INTO table (SELECT * FROM table WHERE column=date)

Is there a way I can see how many rows were inserted during this query?


Solution

  • ExecuteNonQuery - returns the number of rows affected.

    SqlCommand comm;
    // other codes
    int numberOfRecords = comm.ExecuteNonQuery();