Newbie question on comboboxes

  • Thread starter Thread starter mfleet1973
  • Start date Start date
M

mfleet1973

Hi.

I'm practically a .NET virgin.

I have an employee table

EmpID -> Integer
EmpName -> Text

I have another table containing multiple datafields (10) which each
have an EmpID value.

My question is, how can I display the name field value in the 10
separate comboboxes?

Thanks for any replies!!
 
MFleet,

Probably I don't understand your question but if I do; than it is finding
while using from that fisrt combobox the gotten selected value the index
with the findstringexact and set that index to the selectedindex from each
seperate combobox.

I hope this helps,

Cor
 
Thanks for replying.

I'll elaborate a little on my question:

Employee Table

Fields : ID Name
------------------------------
Row1: 1 Mike
Row2: 6 John
Row3: 9 Fred
Row4: 13 Tim

Projects Table

Fields: Emp1 Emp2 Emp3 Emp4 Emp5 Emp6
------------------------------------------------------------------------------
Row1 1 13 9 1 1 13
Row2 6 1 1 9 6 1

In the above example I will have 6 comboboxes on the form. I want to
display the information from the projects table but I do not want to
display the numbers (1,6,9,13). I want to display the names of the
employees (Mike, John, etc.). How can I do this? I don't think that
it is possible to do it with the "DisplayMember" and "DisplayValue"
properties.

Cheers.

Mike.
 
Newbie,

This is not a combox solution this is more a datagrid/datagridview question.
What version do you use, because with version 2005 you can do it all without
one piece of code.
Although it is difficult to explain.

Cor
 
Mike,

Do you actually have a Projects table in a database and the table contains
columns Emp1 thru Emp6?

If so, this table violates the cardinal rule of relational design: no
repeating groups.

I would normalize the table to remove the repeating group. Otherwise, you
will have nothing but problems trying to work with the database.

Kerry Moorman
 
Hi.

So do you suggest only storing the name instead? I need that
information in the projects table.

Cheers.

Mike.
 
Mike,

I may be wrong about your requirements, but here are my assumptions:

1. You need to keep information about employees, such as first name, last
name, email address, etc. For this you need an Employees table with an EmpID
primary key column, along with additional columns for specific employee data.

2. You need to keep information about projects, such as the project's title
or description, start date, end date, etc. For this you need a Projects table
with a ProjectID primary key column, along with additional columns for
specific project data.

3. You need to keep information about which employees work on which
projects. One employee can work on many projects and one project can be
worked on by many employees.

This is a classic many-to-many relationship. It requires a third, or
"linking", table to establish the relationship. In this case you need a third
table, EmployeesProjects, with an EmpID column and a ProjectID column. These
2 columns will together be the table's composite primary key. This table
could also contain additional information, such as how much time a particular
employee has worked on a particular project.

With this design, if the employee with an EmpID of 1 is working on the
project with a ProjectID of 5 there will be a row in the EmployeesProjects
table that looks like this: 1 5

My point is that you need to get the database design correct up front,
before writing any code or worrying about combo boxes, etc.

Of course, I may be completely wrong in my assumptions about your data needs.

Kerry Moorman
 
Hi Kerry.

I can see why you thought the way you did but the employee fields in
the project table are more than who is working on the project. It's
also what their roles are. For example Employee Field # 1 is the
project leader. Employee Field #2 is who is the employee doing the
work. Employee Field #3 is the designer. Employee Field #4 is the
manager. I have 5 others but you see what the issue is.

Thanks a lot for replying!!!

Mike.
 
Kerry has given you the right direction to follow. The fact that you also
need to keep track of 'roles' does not change the advice Kerry gave you.
Simply add another table to the design - 'ProjectRoles' with columns RoleId
and Description and rows like:
1 Project Manager
2 Project Leader
3 Worker Bee etc.

then add another column Kerry's 'EmployeesProjects' Table for the RoleId.
This way you can have an unlimityed number of designers, worker bees, joint
project leaders etc.
 
Back
Top