O'Reilly logo

Sams Teach Yourself ADO.NET in 24 Hours by Paul Bertucci, Jason Lefebvre

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required