Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
<c#>
I have very little experience with programming but I have to create a windows form application with multiple forms. On one of the forms I need to make use of information from an access database. I have an access database with two tables. One table is called Student.

The student table has four columns:
student number
student name
student email
student address

I need to make use of the student name column. It has ten records. I need to load the ten names into a combo box. Once the user selects a name from the combo box, the other details from the table will be displayed in various textboxes on the form. I'm having trouble loading the names into the combo box. The names need to be loaded into the combo box at the start of the program. If I'm going to use the names to load other information do I load the dataset into an array or do I load them directly into the combo box?

Any help or ideas will be very appreciated.

What I have tried:

I have tried to create a student class and then use it like this:

Student aStudent = new Student //the new Student part threw out an error
(dbReader["StudentName"].ToString());
this.cmbStudents.Items.Add(aStudent);
Posted
Updated 27-Apr-16 1:48am
Comments
F-ES Sitecore 27-Apr-16 7:47am    
Your question is basically "How do I write an application", you have listed your requirements and seem to be asking someone to do your homework for you. Break the problem down into parts and solve each part. To understand how you read data from Access look at this

https://msdn.microsoft.com/en-gb/library/aa288452(v=vs.71).aspx

To add items to a combo

https://social.msdn.microsoft.com/Forums/windows/en-US/c7a82a6a-763e-424b-84e0-496caa9cfb4d/how-add-a-item-to-combobox?forum=winforms
chants 27-Apr-16 8:27am    
My apologies, I was simply asking for different ideas on what would be the best way to go about doing it. Thank you for the references.

1 solution

just use this

C#
this.cmbStudents.Items.Add(dbReader["StudentName"].ToString());


Student aStudent = new Student
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900