Executes the specified SqlCommand and returns the number of rows affected.
Namespace: Nemiro.Data.SqlAssembly: Nemiro.Data (in Nemiro.Data.dll) Version: 2.11.4.126 (2.11.4.126)
Syntax
Parameters
- cmd
- Type: System.Data.SqlClient SqlCommand
Return Value
Type: Int32The number of rows affected.
Exceptions
Exception | Condition |
---|---|
SqlException | The exception that is thrown when SQL Server returns a warning or error. |
ValueForIdentityException | An exception occurs if the property of primary key has not flag the Identity and field is autoincrement. |
StringOrBinaryDataWouldBeTruncatedException | An 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()) { SqlCommand cmd = new SqlCommand("UPDATE messages SET hits = hits + 1 WHERE id = @id"); cmd.Parameters.Add("@id", SqlDbType.Int).Value = 42; int used = client.ExecuteNonQuery(cmd); Console.WriteLine("Updated {0} rows.", used); }
See Also