SqlClient ExecuteNonQuery Method (String)Nemiro.Data.dll
Executes a Transact-SQL statement against the connection and returns the number of rows affected.

Namespace: Nemiro.Data.Sql
Assembly: Nemiro.Data (in Nemiro.Data.dll) Version: 2.11.4.126 (2.11.4.126)
Syntax

public int ExecuteNonQuery(
	string sql
)

Parameters

sql
Type: System String
Query SQL, to be executed.

Return Value

Type: Int32

The number of rows affected.

Exceptions

ExceptionCondition
SqlExceptionThe exception that is thrown when SQL Server returns a warning or error.
ValueForIdentityExceptionAn exception occurs if the property of primary key has not flag the Identity and field is autoincrement.
StringOrBinaryDataWouldBeTruncatedExceptionAn exception occurs if some of the fields of the table are added values ​​that exceed the allowable size of a table field.
Remarks

Caching options are ignored.

Examples

using (SqlClient client = new SqlClient())
{
  int used = client.ExecuteNonQuery("UPDATE messages SET hits = hits + 1 WHERE id = 42");
  Console.WriteLine("Updated {0} rows.", used);
}
See Also