I am developing a Windows Form Application against a SQL Server relational database. An example of the database schema is:
TableA
------------------
PK A_ID uniqueidentifier
A_NAME varchar(254)
TableB
------------------
PK B_ID uniqueidentifier
FK A_ID uniqueidentifier
B_NAME varchar(254)
TableC
------------------
PK C_ID uniqueidentifier
FK A_ID uniqueidentifier
C_NAME varchar(254)
In the form I have a ComboBox (cboA_ID) to select the TableA record (DataSource = TableA, DisplayMember = A_NAME, ValueMember = A_ID) and a TabControl where controls on each tab are bound to fields in either TableB or TableC.
My question is, is it possible to bind cboA_ID to TableB.A_ID and TableC.A_ID?
This is my first database application so if there is a better way to do this I’m all ears. I have set everything up using the wizards in Visual Studio 2010, so I’m still not 100% familiar with what all the various TableAdapters and DataSets do.
Thanks for the help.
You probably can’t have the ComboBox databinded (databound?) to both tables at the same time — they would be fighting each other as to which value should be displayed in the ComboBox and would most likely end up corrupting your data tables with the wrong data.
You would either need a separate ComboBox for each tab, or change the databinding of the ComboBox based on the current tab.