Newbie: Help with DataAdapter- Datasets

  • Thread starter Thread starter steve
  • Start date Start date
S

steve

Hello,
I've been struggling with the following problem for a while now and although
i made it work halfway i still dont think I understand the principles
correctly....

I want to populate a few controls from a dataset, in other words they will
be synchronized. ( you scroll on the name the address will change
accordingly, etc.)

Now, I want the user to be able to choose the info (Tables) that will
populate the controls, so i put two radio boxes.
( Customers OR Employees)
BUT for either table I need info from a *corresponding* table. They are
related. (CustomerInfo and EmployeeInfo).since there will be some controls
populated from these (child) Tables.
In other words: I want to populate according to user's choice with:
Customers - CustomerInfo OR Employees - EmployeeInfo.

I have :

* 1 * DataConnection
* 2 * DataAdapters
* 1 * DataSet

And depending on the user's choice I use .Fill for the corresponding
adapter. It works for one Table at a time, but not for the child table as
well.

How do I pass the relational info (JOIN) for the corresponding child tables?
Through the Adapters' SELECT statement OR later I use the DataSet's Relation
property?

What is the best (only?) way to have something like that?

Thanx in advance for any help/links.
_steve_
 
Steve,

The important part that ur missing (light bulb goes on here) is ---

"Fill" will not fill in database structure information. And relations are
part of structure information.

If the employee info and customer info structures are pretty much the same,
you could resort to using a strongly typed dataset with "person" and
"personinfo" something like that. Then, you can use a batched query as a
part of ur stored proc, or two independent queries to fill in both person
and personinfo in either one call or two calls to sqldataadapter
respectively.

Now comes the other part of setting up the relation between the two. There
are 3 ways to do this.

a) call fillschema - not recommended (atleast by me, because the queries it
executes are too heavy).
b) setup a datarelation programatically within the dataset.relations
collection, and then you can getchildrows method. (or databinding will
understand this too)
c) Use a dataview.

b -- is my recommended approach.

Hope that helped.

- Sahil Malik
You can reach me thru my blog at
http://www.dotnetjunkies.com/weblog/sahilmalik
 
Back
Top