Using ExecuteNonQuery()

The ExecuteNonQuery() method of the Command object is used to send a SQL command to the data source for processing. Any SQL command you want to send to the data source that will not return any data (or more specifically, any data that you don't plan to use) should be sent using the ExecuteNonQuery() method.

In the next several sections, you'll see how to use the ExecuteNonQuery() method to insert, delete, and modify data.

Inserting New Data

Recall from Hour 3, “Using T-SQL: A Crash Course,” that inserting new data into your data source is done using the SQL INSERT statement. One of the easiest ways to add data to a table in your data source is to build the INSERT statement dynamically and then send it to the data source ...

Get Sams Teach Yourself ADO.NET in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.