Repeat the above steps to update the address of the
customers. Select “Update” option in step 3, provide a method name in the next
step and give the following query that will update the address, city, region,
postalcode, country, phone and fax by giving the customerid.
The update query will be:
UPDATE [Customers]
SET [Address] = @Address,
[City] = @City,
[Region] = @Region,
[PostalCode] = @PostalCode,
[Country] = @Country,
[Phone] = @Phone,
[Fax] = @Fax
WHERE (([CustomerID] = @Original_CustomerID)) .
So our final dataset in designer will look like:
Figure 10 – Final Customer table view
How to use the functionality?
To execute the above functionality instantiate the Table
adapter.
Listing 5: Instantiating TableAdapter
TestTableAdapters.CustomersTableAdapter ada = new
TestTableAdapters.CustomersTableAdapter();
Now we can see the new select and update functionality with
the insert, update and delete method in TableAdapter intellisense.
Figure 11 – Visual studio intellisense for
TableAdapter
We can use the above functionality:
Listing 6: Using the new functionality
//Update Address
ada.UpdateAddress("2nd Cross", "Bangalore", "Karnataka", "560061",
"India", "123456789", "!23456789", "100");
//Get details by customerid
grdCustomers.DataSource = ada.GetDataBy("100");
grdCustomers.DataBind();
In the next section we will construct a custom typed dataset
using visual studio instead of dragging and dropping from server explorer.