Solved

Create a Combo Box in a form that then updates a data grid view

Posted on 2014-11-18
4
174 Views
Last Modified: 2014-11-25
Ok very new to this.  I am using Visual Studio 2013.  I have 3 tables I am working with from a database the database is called GC_Emp_data, the tables are TrainingCourse, Positions, and then Training_Positions.  The training course has a list of all the courses the positions has all positions, and the last table merges the to together via the ID number.  So a training course could be in multiple positions.  What I wanting to do is Select a Training course via a combo box and then it populate a datagridview that will allow me to see what positions that it's has assigned in the (training_posoition table) and also allow me to add new positions to that table.  Not sure where to start and cannot find the right starting point.
0
Comment
Question by:sharris_glascol
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
dustock earned 500 total points
ID: 40450060
You'll need to query your TrainingCourse table to populate your combo box and return a dataset or datatable with the courses.  Then you'll need to provide information for the following to load up the combo box.

            comboBox1.DataSource = //DataSet name or datatablename
            comboBox1.ValueMember = //database column name, probably the course ID
            comboBox1.DisplayMember = //database column name, probably the name of the course

Open in new window


Once you have the combobox populated you'll want to create an event for the selected index changed (double click the combo on your form) so that when a course selection is made you can have your program query the Training_Positions table based on the valuemember of your course selection.  Then return a dataset or datatable with the results and set the datasource of the datagridview to the name of the dataset or datatable

dataGridView1.DataSource = //dataset or datatable name

Open in new window


As far as adding new positions, how were you envisioning you would accomplish that task?  Do you have the pieces in place to be able to connect and query your database from your program or do you need help from the ground up?
0
 

Author Comment

by:sharris_glascol
ID: 40450084
All I want to do is in the datagridview is add positions via a combo box that references the positions table and updates the training/positions table.
0
 
LVL 9

Expert Comment

by:dustock
ID: 40450116
Then you'll need to load a combobox with the list of positions and when you select one and click a button, or just select one you can run an insert statement and then query your database again to get the updated view in your datagridview.  

I can help you accomplish any of this, but I need more information on what you need help with.  The more vague you are in your request the more difficult it is for myself and other experts to assist you.  Do you need help with the code, the queries, the logic?  Do you have any code in place that you've tried but need help to debug?
0
 
LVL 33

Expert Comment

by:it_saige
ID: 40458460
Using what I have understood to be your requirements.  I threw together this quick example in VS2013.  Let me know if this is what you were after.

-saige-
EE-Q28564627.zip
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
the term "Features Not Supported in the Next Version of SQL Server" 12 30
Help with Sorting Full Text results 2 14
Sql query 107 30
Query / Window function ? 3 18
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now