Display data from multiple tables in one datagridview (not using a query)

kanaida

Member
Joined
Oct 6, 2009
Messages
15
Programming Experience
3-5
here's my scenario:

Say I have 2 tables:

TERM (payment terms of an order, 2 fields: TermID, TermDescription)
ORDER (the order itself, lots of fields: OrderID, PO, etc...)

let's say I'm trying to show the term description on and the order itself on one grid. I accomplished this by:

Creating a bindingsource to the order table,
bind it to the datagridview,

In the datagridview column that is called TermID,
modified this to a combobox,
use the TERM table as datasource,
TermID as value, and TermDescription as description.

No messy queries. You can do this with as many tables as you need to so long as the table structure makes sense.

Other uses:
to display tables like UserInGroup with 2 fields, but you want to show more data from both the User table and the Group Table to display something like:

Group, GroupCreatedBy, UserId, UserFullName
 
Having the database join the data is better because:

That is what it was designed to do
It does it faster and in a more optimal way than a combobox
It's quicker to write the SQL than mess around adding tens of DataGridViewComboBox to your DGV and configuring them all
You don't have to download massive amounts of data to be able to cope with all possible combinations (in your example, choose either: download all terms so that every order has a successful join [heavy] or download only the terms for termid in the current order [a waste of your time because it's a slwoer way of doing exactly the same join as using a proper DB join] )

Use a screwdriver for the screws, not a knife or a coin..
 
Back
Top