Firstly have a look at that sql command
select * from Course Number and Name
What is the name of the table? As far as SQL is concerned then it is "Course" and "Number and Name" just throw an error - which is why you don't get your combobox populated.
If you really must use spaces in your table names ( = bad idea ) then you must surround the table name with square brackets, so the query becomes
select * from [Course Number and Name]
The same applies to the column of the same name
course_Number_and_NameComboBox.DisplayMember = "[Course Number and Name]";
As to the second part of your question, when a row is selected in the ComboBox the
course_Number_and_NameComboBox.SelectedText
property will be set to the visible text (i.e. the value that was in
[Course Number and Name]
) and the
course_Number_and_NameComboBox.SelectedValue
property will be set to the
ValueMember
- i.e. the value that was in
ID
If you want any other data from the datatable you will have to look it up based on the ID