Multiple tables in my dataview

J

Jason L James

Hi all,

does anyone know if I can create a dataview
from multiple datatables. My dataset is constructed
from four separate tables and then the relationships
are added that link the tables together. To make
data entry easier I would like to combine selected
columns from the four tables onto a single dataview that
could be used as the datasource for a datagrid
control. The distinct updates, insert ans delete
commands would then be used to update the datatables
in the dataset and write the changes back to the
database.

If this is not the way the problem I have should be
answered then please feel free to offer any alternatives.

Many thanks,

Jason.
 
J

Jason L James

Thanks for the info. However, I would like to be able
to view all fields contained in the multiple table
relationship on the same line of my datagrid,
as though I had performed a select query with
mutliple joins in it. The porblem with using a
select query with data from multiple tables is that
I can not then use the dataadapter.update
command to pass the information back to the
database.

Any more ideas, or reasons why this might not
be possible?

Thanks,

Jason.
 
O

One Handed Man \( OHM - Terry Burns \)

Whats wrong with using the update function on each adapter ? just call 4
adapters in turn, alternatively, you could manually do this in code.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing
 
J

Jason L James

Using the four DAs is no problem with a dataset with
related tables. This however spreads the information
over the four tables and so the user can not see the
information from all four tables at the same time on the
data grid. They have to traverse the realtionships to
get the the related data. I would prefer all of the data
from the four tables an the screen, and editable in
a datagrid a the same time is at all possible.

Thanks for persevering.

Jason.
 
O

One Handed Man \( OHM - Terry Burns \)

You might want to try and see if a third party grid will do this, I
understand there are a few of them on the market, perhaps one will do what
you need.

Other than than you may be forced to conjuring up some sort of middleware
object that handles all this, perhaps a custom control even, a lot of work
me thinks.

I'm sure your not the first one to ask for this, but I must say, your the
first that I remember, perhaps another solution is to re-think the design
based on what the objects will currently do ?

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing
 
J

Jason L James

Many thanks for your help.

Jason.

You might want to try and see if a third party grid will do this, I
understand there are a few of them on the market, perhaps one will do what
you need.

Other than than you may be forced to conjuring up some sort of middleware
object that handles all this, perhaps a custom control even, a lot of work
me thinks.

I'm sure your not the first one to ask for this, but I must say, your the
first that I remember, perhaps another solution is to re-think the design
based on what the objects will currently do ?

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing
 
O

One Handed Man \( OHM - Terry Burns \)

OK, good luck and I would be interested in knowing what solution you came up
with in the end as someone, perhaps me even, will ask this again.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing
 
J

Jay B. Harlow [MVP - Outlook]

Jason,
In addition to the other comments.

The only ways I can think of is to denormalize the data, use 4 grids, or
possibly a JoinView...

I would favor the 4 grids...

You could denormalize the data into a single table, The caveat being updated
components...

The following sample using 3 grids is taken for a Northwind Sample:

customerAdapter.Fill(customerDataSet, "Customers")
orderAdapter.Fill(customerDataSet, "Orders")
orderDetailsAdapter.Fill(customerDataSet, "OrderDetails")

' Create relationships.
customerDataSet.Relations.Add("CustomerOrders", _
customerDataSet.Tables("Customers").Columns("CustomerID"), _
customerDataSet.Tables("Orders").Columns("CustomerID"))

customerDataSet.Relations.Add("OrderDetails", _
customerDataSet.Tables("Orders").Columns("OrderID"), _
customerDataSet.Tables("OrderDetails").Columns("OrderID"))

' Bind to a DataGrid.
Me.DataGrid1.SetDataBinding(customerDataSet, "Customers")
Me.DataGrid2.SetDataBinding(customerDataSet,
"Customers.CustomerOrders")
Me.DataGrid3.SetDataBinding(customerDataSet,
"Customers.CustomerOrders.OrderDetails")


There is a JoinView sample custom DaveView class for VB.NET that you might
be able to modify to do what you want...

See:
http://support.microsoft.com/default.aspx?scid=kb;en-us;325682

Basically you create a new JoinView object, set the properties for your
join, then use this JoinView object as the DataSource on your DataGrid.

Hope this helps
Jay
 

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

Top