cjard
Well-known member
- Joined
- Apr 25, 2006
- Messages
- 7,081
- Programming Experience
- 10+
... i cant see a walkthrough (http://msdn2.microsoft.com/en-US/library/wzabh8c4(VS.80).aspxhttp://msdn2.microsoft.com/en-US/library/wzabh8c4(VS.80).aspx) for feching data into the app from 2 related tables..
I know i can create a tableadapter associated with one or another table, and this TA can have an associated query that performs a join but then its an issue of encapsulation for me...
suppose i have Customers and Orders tables and i want to show a customer and his orders on my form.. and my DataSet has a DataTable for each database table and a DataRelation object has been created between the two.. so the dataset knows of how to join the two tables..
where does the join go? Do i call GetData() on the customers with 123 as the customer id, then call GetChildRows() to pull the related orders? i.e. the database doesnt do the join - i get the customer details (and suppose he has customer ID 123) then make another db call (for the orders) and get the orders for customer ID 123. or do i call GetData() on the orders table adapter, again passing the 123 customer id..
what if there are multiple links to this table, what do i get back if i use get child rows?
Or suppose i perform a join in a query and have it added to one or the other tableadapters can call it GetCustomerAndAllOrders(byCustomerID)
which table adapter should contain it, customers or orders? why?
how do these both go with the notion of having a Form, and drag/dropping fields out of the data sources window and onto the form, binding them to the data and having binding navigators to scroll it. anyone have any good walkthroughs on this, for multiple tables?
there are walkthroughs for writing data back into multiple tables, but i havent seen anything for advice on how to read data out of multiple tables. my instinct tells me to create a query that does the join.. so i can create a view on the DB and treat it like a table, import it into my data set and bind the controls to it.. and for updates i can write custom Insert/Update queries attached to the tableadapters for the individual tables (also members of the data set) and call those to do the updates..
but is this the way it is done? am i making somethig too hard for myself here when i should maybe jsut be calling someDataSet.InsertNewRows() instead of calling ordersTableAdapter.myCustomInsertCommand(txtOrderItem.Text, txtQuantity.Text, txtBlah.Text)
matt
I know i can create a tableadapter associated with one or another table, and this TA can have an associated query that performs a join but then its an issue of encapsulation for me...
suppose i have Customers and Orders tables and i want to show a customer and his orders on my form.. and my DataSet has a DataTable for each database table and a DataRelation object has been created between the two.. so the dataset knows of how to join the two tables..
where does the join go? Do i call GetData() on the customers with 123 as the customer id, then call GetChildRows() to pull the related orders? i.e. the database doesnt do the join - i get the customer details (and suppose he has customer ID 123) then make another db call (for the orders) and get the orders for customer ID 123. or do i call GetData() on the orders table adapter, again passing the 123 customer id..
what if there are multiple links to this table, what do i get back if i use get child rows?
Or suppose i perform a join in a query and have it added to one or the other tableadapters can call it GetCustomerAndAllOrders(byCustomerID)
which table adapter should contain it, customers or orders? why?
how do these both go with the notion of having a Form, and drag/dropping fields out of the data sources window and onto the form, binding them to the data and having binding navigators to scroll it. anyone have any good walkthroughs on this, for multiple tables?
there are walkthroughs for writing data back into multiple tables, but i havent seen anything for advice on how to read data out of multiple tables. my instinct tells me to create a query that does the join.. so i can create a view on the DB and treat it like a table, import it into my data set and bind the controls to it.. and for updates i can write custom Insert/Update queries attached to the tableadapters for the individual tables (also members of the data set) and call those to do the updates..
but is this the way it is done? am i making somethig too hard for myself here when i should maybe jsut be calling someDataSet.InsertNewRows() instead of calling ordersTableAdapter.myCustomInsertCommand(txtOrderItem.Text, txtQuantity.Text, txtBlah.Text)
matt