inserting to multiple tables in one form

  • Thread starter Thread starter Tyro
  • Start date Start date
T

Tyro

I have a form that needs to add a customer and customer history in one form.

customer (custid) --->custdetail (custid)

Is there anything easy in asp.net using DataAdapter, Dataset or DataTable to
do this?

What's the best practice for doing this kind of stuff?
 
Let's assume that you want to hold all of this data locally, rather than
making individual database hits (which are expensive) every time that you
select a new customer.

First, you set up a data adapter for both the customer list and the customer
history. You then fill your DataSet with each of these DataTables, based on
these adapters. Now, you have an in-memory representation of both tables.

To navigate children, you need to create a DataRelation object that
establishes the relationship between these two.

Using this, you can now get the child rows of each DataRow in your customer
DataTable, and use this to databind to your second DataGrid.
 
Back
Top