how to fill the combobox with data from different column from different table..??

alfiecrosby

New member
Joined
Apr 16, 2008
Messages
4
Programming Experience
Beginner
Hi..

How can I fill the combobox with data from different column from different table..??

example:

I have two table:
person1 with column name1
person2 with column name2

so..combobox will consist of name1 and name2

is it possible..?? if so..how can I do this or what the codes or just a hint...


many thanks for reply...
 
You need to be a bit more clear in your post. It is possible that this can be done with a join through SQL or through code depending on what you are actually asking.


SELECT a.name + ' | ' + b.name as ComboContents
FROM tbl_table1 a, tbl_table2 b
WHERE a.id = b.id

And with a datareader you could populate the combo box fairly easily and quickly. Otherwise you may need multiple datareaders containing sorted contents that you could loop through and get what you need. But it will be difficult to make sure this is correct if that data is in different tables. I think that you were asking about a join. You will need to join the two tables and query them like above and you should be able to populate your combo box.
 
ss730's right, this needs doing with a JOIN.. Do strive for using ANSI join syntax though ;)
 

Latest posts

Back
Top