Submitting Updates Using Parameterized SqlCommands

Let’s set aside the SqlDataAdapter class for just a moment. As in the preceding simple snippets, you can already submit updates using parameterized SqlCommands.

Submitting a New Row

You can execute the following parameterized INSERT query to add a new row to your table. The syntax is straightforward. Specify the table name, a parameterized list of column names, and a parameterized list of parameters. For more information about the various options available on an INSERT query, see the documentation for your database’s query language.

INSERT INTO [Order Details] (OrderID, ProductID, Quantity, UnitPrice)
    VALUES (@OrderID, @ProductID, @Quantity, @UnitPrice)

In Chapter 4, you learned how to create a

Get Programming Microsoft® ADO.NET 2.0 Core Reference, 2nd Edition 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.