Using SqlCommand and SqlParameter Objects to Update the Northwind Database

NOTE The codefor the walkthrough in this section can befound in the Updating Data Using ADO.NET.sln solution file. Listing 6.1 is contained within the click event of the Inserting Data Using DataAdapters With Mapped Insert Commands button.

The DataAdapter gives you a simple way to map the commands by using its SelectCommand, UpdateCommand, DeleteCommand, and InsertCommand properties. When you call the Update() method, the DataAdapter maps the appropriate update, add, and delete SQL statements or stored procedures to their appropriate Command object. (Alternately, if you use the SelectCommand property, this command would execute with the Fi11() method.) If you want to perform an insert into the Customers table of the Northwind database, you could type the code in Listing 6.1.

0 0

Post a comment

  • Receive news updates via email from this site