ExecuteNonQuery used for executing queries that does not return any data. It is used to execute the sql statements like update, insert, delete etc. ExecuteNonQuery executes the command and returns the number of rows affected.
##will work with Action Queries only (Create,Alter,Drop,Insert,Update,Delete). ##Returns the count of rows effected by the Query. ##Return type is int ##Return value is optional and can be assigned to an integer variable.
ExecuteNonQuery is typically used for SQL statements without results (e.g., UPDATE, INSERT, etc.).
ExecuteNonQuery() is a predefined member method of Command Class.which is used to execute backend commands when the connection is opened with the central database such as executing the Sqlcommands from the .cs code
if we perform any changes on database data.............use executenonquery()
Executenonquery() is used to perform any ddl or dml task
ExecuteNonQuery() used for Insert,Update,Delete Statements
The ExecuteNonQuery() performs Data Definition tasks as well as Data Manipulation tasks also. The Data Definition tasks like creating Stored Procedures ,Views etc. perform by the ExecuteNonQuery() . Also Data Manipulation tasks like Insert , Update , Delete etc. also perform by the ExecuteNonQuery() of SqlCommand Object.Although the ExecuteNonQuery returns no rows, any output parameters or return values mapped to parameters are populated with data.The following ASP.NET program insert a new row in Discount (Pubs database) table using ExecuteNonQuery();
ExecuteNonQuery() is used to define number of records affected. you can use it for Insert,Update,Delete functionality.
Execute Non Query is ADO.Net Object it is used for execute SQL Statement for Insert,Update Delete, and it does not return any value
It is use to excute the command which returns no record like our insert,update and delete opration.
Hello friend,Executes a Transact-SQL statement against the connection and returns the number of rows affected.You can use the ExecuteNonQuery to perform catalog operations (for example, querying the structure of a database or creating database objects such as tables), or to change the data in a database without using a DataSet by executing UPDATE, INSERT, or DELETE statements. Although the ExecuteNonQuery returns no rows, any output parameters or return values 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. When a trigger exists on a table being inserted or updated, the return value includes the number of rows affected by both the insert or update operation and the number of rows affected by the trigger or triggers. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1.