Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have a doubt, how can I select an identity that I am receiving from the database, inside my comboBox?

example:

table CARS

Mark | Model | Engine
BMW  |  M5   |   10
BMW  |  M3   |  123
BMW  |  M5   |  147

VW   | Golf  |  789
VW   | Fox   |   12
VW   |  CC   |  107



When I write txt_mark.text = "BMW" ... then
appears in the comboBox, all BMW model data: m5, m3 ...
and if I select one of them,in side of comboBox_Model,"M5", it should appear the following engine numbers: 10 and 174.

already tried this code :
SQL
select a.mark, a.model, a.Engine
from cars
where a.mark = ('"& txt_mark.text &"')
VB
'(BMW)


VB
'/ / this it will return, comboBox_model = "M5" and "M3" and if i select one of them the model "M5" or "M3" , and this will get all that there: 10, 123, 174 in cbx_Engine.
problem: if m5 then 10, 145 and not all....if m3 then 123  and not all..


SQL
select a.mark, a.model, a.Engine
from cars
where a.mark = ('"& txt_mark.text &"') and a.model = ('"& cbx_model.text &"')


VB
'/ / this it will return, comboBox_model = "M5" and "M3" and the cbx_Engine nothing, empty.



Objective: When you select a comboBox_Model the items of the list, then will appear the  number of that model.


Can anyone show me another way ?
If you help me,I will appreciate.

With best regards,
Nillo123.
Posted
Comments
Mahesh Bailwal 28-Jun-13 7:21am    
what are you getting cbx_model.value? Is it Model or Engine?
Nillo123 28-Jun-13 8:20am    
model
Mahesh Bailwal 28-Jun-13 9:09am    
Your Problem is :if m5 then 10, 145 and not all....if m3 then 123 and not all..

So this happening as you are using modal number in query
a.model = ('"& cbx_model.text &"')

So this seems logical. Please correct me If I am wrong.
Nillo123 28-Jun-13 9:41am    
sorry .. :( I did not express myself well, what I meant to right was:
"the problem is : If a select a model, like "M5", for example, from my comboBox_Model then in the next comboBox, comboBox_Engine, will appear all engine numbers, including the VW."

but what i want is : if i select M5 in my comboBox_model, then i will have access to other comboBox, comboBOx_Engine(and here will appear only and just the engines that i have in my table, with model M5) result = 10;147
Mahesh Bailwal 28-Jun-13 10:04am    
Can you share your code. To make it clear

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