jordi mari

jordi mari

  • NA
  • 4
  • 3.1k

DISPLAY LISTBOX ITEMS FROM A COMBOBOX ITEM THROUGH A JUNCTION TABLE

Apr 20 2009 4:58 PM
This is the question:I want to select a book with many authors in a ComboBox and see all their names in a ListBox. In other examples, like Customers-Orders-OrderDetail, there is an “one to many” relation folowed by another “one to many” relation. That’s not my case! In my problem there is an "one to many relation" (one title has many authors) followed by a "many to many relation" each one of these authors has a name. A Title may have many Authors, and an Author may have many Titles. This is why I need the junction table. I'm using Microsoft Visual C# Express Edition 2008 and SQL Server Express Edition 2008. It looks very simple! But I can't get a code that solves this problem! I have this 3 Tables CREATE TABLE Titles ( TitleID int IDENTITY(1,1) PRIMARY KEY TitleName varchar (50) NOT NULL ) CREATE Authors ( AuthorID int IDENTITY(1,1) PRIMARY KEY AuthorName varchar (50) NOT NULL ) CREATE AuthorsTitles ( TitleID int NOT NULL AuthorID int NOR NULL CONSTRAIT PK_AuthorsTitles PRIMARY KEY ( TitleID, AuthorID ), FOREIGN KEY (TitleID) REFERENCES Titles (TitleID) FOREIGN KEY (AuthorID) REFERENCES Authors (AuthorID) )