The query that im using is
SELECT firstName + ', ' + lastName FROM employees
ORDER BY lastName
Which returns a table of values like
Workman, Bob
Nevarez, Ray
and so on, which is what I wanted. I’m using this query to populate a combobox full of employees. My question is, now that these results are put together like that, is it possible to use them in any way as an index? I want to be able to select that person in the combo box, hit the submit button, and have it pull up their profile. But since the combo box is only storing things like “Workman, Bob” im not sure what I would use to find that person in the next query. Does that make sense? Any ideas?
Preferrably, you would use the primary key (probably
employee_id) from your table as the index.Your query would look like this (or similar):
Then, you’d use
employee_idas the value of the option andfullnameas the text/display. You can then link directly to the user by referencing their ID.If you went by name only, it’s possible two people could have the same name which would no doubt cause you some headaches.
Edit:
Using windows forms, you can bind the combo-box to a DataTable (containing your results) by doing something like this: