ExecuteNonQuery executes a Transact-SQL statement against the connection and returns the number of rows affected.
vb.net command.ExecuteNonQuery()
C# command.ExecuteNonQuery();
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();
Default.aspx
Untitled Page
Click the following links to see full source code
Advertisement