inserting to multiple tables in one form

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?
 
C

Chris Jackson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top