combo box filter

sigridish

Member
Joined
Nov 10, 2011
Messages
22
Programming Experience
Beginner
hi all! i have two combo box in my program

one has the subteam for example if you click the 1st combo box, the items would be
A1
A2
A3
A4
A5
what i want to happen is that if i chose A1 only the members of team A1 would appear in my combo box2. and by that, you need an sql statement. but how do i code that? can someone help me?
 
If the data is coming from a database, as it sounds like, then you have two choices:

1. Get only the data you need for the second list only when you need it.
2. Get all the data upfront and filter locally.

If the total amount of data is relatively small then I'd go with the second option. To that end:

Master/Detail (Parent/Child) Data-binding
 
well i tried this code


VB.NET:
dim sql as string
sql = "Select * from finaltickettable where Subteam = '" & cboselect.Text & "'"
If cboselect.SelectedIndex = 0 Then
            cboselect2.Items.Add(sql)

whenever i execute the program, the data in my 2nd combo box is Select * from finaltickettable where Subteam = '" & cboselect.Text &
 
All you're doing is creating a String containing some SQL code. You have to actually execute that SQL code against the database to get the result set of the query. Presumably you already know how to do that because you would have done it to populate the first ComboBox. If you don't, check this out:

Retrieving and Saving Data in Databases
 
kasi pag select ko ng A1 dapat ang lalabas lang sa combo box2 is members ng A1. di ko pwede mano mano yun kasi bka mag dagdag ng members. OJT lang ako. hehe.
 
ang gamit ko for my database is mysql query browser. meron dito sql server 2005 na nka install. pag gawa ko po ng database nilagay ko po sila dun
 
Back
Top