ExecuteNonQuery Method

Executes a statement that does not return a result set, such as an Insert, Update, Delete, or a data definition statement.

Syntax

int ExecuteNonQuery( )

Return Value

The number of rows affected.

Implements

IDbCommand.ExecuteNonQuery

Usage

  • You can use ExecuteNonQuery to change the data in a database without using a DataSet. Do this by executing Update, Insert, or Delete statements.

  • Although ExecuteNonQuery does not return any rows, output parameters or return values that are mapped to parameters are populated with data.

  • For Update, Insert, and Delete statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1.