Click here to Skip to main content
15,888,330 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello world!
i have a doubt...
my project "visual basic"

i have a comboBox, with information from databaseOracle,
that when my combobox.text receive the information i must select one of the options that was gives to me.

after i select the item from combobox.text, my other combo will be : combobox.enabled = true, and i will pike the item of combobox

problem: how can i select a item from combox and get me the details that i want in another combobox?

to understand better my program its like a stand car


If you help me,I will appreciate.

With best regards,
Nillo123.
Posted
Comments
Sadique KT 5-Jul-13 7:58am    
pass selected text from combobox1 to database and retrieve the data for combobox2 frm DB.
You can use seleceted Index changed event or editvalue changed or any other events..
[no name] 5-Jul-13 8:38am    
I have absolutely no idea what "a stand car" is but you need to research "cascading comboboxes"

1 solution

Double click on combobox in form design it will open combobox selected index change event for you.
In that event write code for retrieving data from database.
To get value of selected item of combobox:
VB
dim str as string =combobox1.selecteditem 

and use it with select query in where clause, store that data in dataadapter and fill dataset

In below example I am using sql server database:
Example:

VB
Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
       Dim str As String = ComboBox1.SelectedText

       Dim cn As New SqlConnection("Connection String")
       Dim cmd As New SqlCommand("Select subitem from ItemMaster where subitem='" + str + "'", cn)
       cn.Open()

       Dim da As New SqlDataAdapter(cmd)
       Dim ds As New DataSet
       da.Fill(ds)
       ComboBox2.DataSource = ds.Tables(0)

   End Sub
 
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