![]() |
| ||
| filling data in combo box from SQL server Dear all, I wanted to fill the combo box with the data from my SQL server database. There are two column in the table, product_id and product_name. for example: product_id| product_name ---------- -------------- 1| pencil 2| NoteBook I was successful in displaying the product name in combo box. The code is given below. I wanted to show the product_name in the combo box and when the user selects the product_name from combo box i should be able to get its product_id. How do i do it? Please help me guys for my academic project. Below is my code. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Private Sub cmbCproduct_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbCproduct.SelectedValueChanged |
| ||
| Re: filling data in combo box from SQL server Use another SQL statement. Construct it like this- Dim strSQL2 As String = "SELECT product_id FROM product where product_name=" & Me.cmbDropDown.SelectedItem |
| ||
| Re: filling data in combo box from SQL server The problem with this query is that i can have some of the "product_name" same. Any idea?? Quote:
|
| ||
| Re: filling data in combo box from SQL server you must have other key to differentiating the same product_name. |
| All times are GMT -4. The time now is 8:04 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC