O'Reilly logo

Sams Teach Yourself ADO.NET in 24 Hours by Paul Bertucci, Jason Lefebvre

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required