Hour 7. Modifying Database Data

As you saw in the preceding hour, the Command object is used in conjunction with the DataAdapter object to retrieve records from your data source and place them into a DataSet, which can then be displayed or manipulated. However, suppose you want to insert data, delete data, or perform any other valid action on the database that doesn't return any records. For this, you can use the ExecuteNonQuery() method of the Command object.

The ExecuteNonQuery() method executes a SQL statement against your data source. In this hour you'll see how to apply the SQL statements from Hour 3, “Using T-SQL: A Crash Course,” to

  • Insert new data into the database

  • Delete data from the database

  • Modify data in the database

The examples in ...

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.