Modifying Data with UPDATE and DELETE

So far, you have seen how to retrieve and add data to the database. However, suppose you would like to modify existing database rows. To modify data, you would use the UPDATE SQL statement. A simplified version of the syntax of the UPDATE statement looks like the code in Listing 3.3.

Listing 3.3. The Syntax of the UPDATE SQL Statement
UPDATE
     table_name
SET
     column_name = expression
WHERE
     search_conditions
				

The specific example in Listing 3.4 explains the syntax quite well. After the statement in Listing 3.4 is executed against the data source, any employee with last name of “Peacock” and first name of “Margaret” as specified by the WHERE clause will be changed to “Hogue” as specified by the SET clause of ...

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.