Using the CommandBuilder

Normally when you go about updating, deleting, or inserting data via the DataSet, you fill the dataset, make your changes to the DataSet, and then issue an explicit update (DELETE or INSERT) command. Listing 19.1 shows a typical update process:

Listing 19.1. The Update Process (19NormalUpd.vb)
 Dim dbConn As SqlConnection = New SqlConnection("Data Source=localhost; Integrated Security=SSPI;Initial Catalog=northwind") Dim CustomerAdapter As SqlDataAdapter = New SqlDataAdapter ("SELECT CustomerID, ContactName FROM Customers", dbConn) CustomerAdapter.UpdateCommand=New SqlCommand ("UPDATE Customers SET ContactName=@ContactName " & _ "WHERE CustomerID = @oldCustomerID", dbConn) CustomerAdapter.UpdateCommand.Parameters.Add ...

Get Sams Teach Yourself ADO.NET in 24 Hours now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.