Click here to Skip to main content
11,639,126 members (69,015 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL VB.NET
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 :
select a.mark, a.model, a.Engine
from cars
where a.mark = ('"& txt_mark.text &"')
'(BMW)

'/ / 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..

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

'/ / 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 28-Jun-13 1:08am
Comments
Mahesh Bailwal at 28-Jun-13 7:21am
   
what are you getting cbx_model.value? Is it Model or Engine?
Nillo123 at 28-Jun-13 8:20am
   
model
Mahesh Bailwal at 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 at 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 at 28-Jun-13 10:04am
   
Can you share your code. To make it clear
Nillo123 at 28-Jun-13 10:24am
   
yes
jenitshah at 28-Jun-13 7:32am
   
Are you sure added Code line to clear ComboBox whenever you fill It with query ?
i.e. ComboBox.Items.Clear()
Nillo123 at 28-Jun-13 9:45am
   
yes

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

  Print Answers RSS
0 OriginalGriff 9,061
1 Sergey Alexandrovich Kryukov 8,773
2 Mika Wendelius 7,027
3 Suvendu Shekhar Giri 2,494
4 F-ES Sitecore 2,438


Advertise | Privacy | Mobile
Web01 | 2.8.150728.1 | Last Updated 28 Jun 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100