Displaying Many-To-Many Database relationship in VB.NET 2008 with DataGrid, MS SQL 2008

Posted by user337501 on Stack Overflow See other posts from Stack Overflow or by user337501
Published on 2010-05-10T17:23:29Z Indexed on 2010/05/10 17:24 UTC
Read the original article Hit count: 495

Filed under:
|
|
|
|

Computer bombed while posting this, couldnt find a duplicate question but if there is one, forgive me.

So, I've run into a wall. And rather than use a ladder to avoid it, I'd like go through it.

I'm setting up what I can best describe as a many-to-many relationship in a database. To examplify, imagine I have three primary tables: Items, Categories, Sections(nevermind the potential redundancy)

Then I have another table, Properties.

Items, Categories, and Sections can be associated with many properties.

A single property can be associated with one, all, or none of the other tables.

The best way I can figure to do this is to have join tables make the relationship.

i.e. tblItems---->(Foreign Key)---->tblItems_To_Properties---->(Foreign Key)---->tblProperties

In this example, tblItems simply has an "ItemID" Primary Key. tblItems_To_Properties has its own Primary Key(tblItems_To_PropertiesID), a Foreign Key to the Item(ItemID) and a Foreign key to the Property(PropertyID). The Properties table simply has its primary key(PropertyID)

I hope this example isnt too confusing...if I have to I can find a way to put a diagram up or something.

My problem is, I want to display this in a DataGrid using the Master-Detail method(DevExpress GridControl). I use the tblItems as a test, and I can see the Items in the parent view, but in the child view I see(understandably) the join table and that is it. My goal is to make it so the Grid ignores the join table and shows the Properties table as the only child.

Any help on this method or insight into another solution would be muuuuuuuch appreciat

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about datagridview