query in combobox

srivalli

Well-known member
Joined
May 4, 2005
Messages
189
Programming Experience
Beginner
hello friends ,
good afternoon
i am back with my queries

in my form i have 4 comboboxes, and the data in each combobox is coming from one master table each

now my query is
when i am selecting first combobox,the data is coming from back end to the combobox1.
and when i am selecting combobox2,combobox1 data is disappeared .
and when i select combobox3 ,data in combobox2 data is not displayed
now what to do
any suggestions
thanks
 
code for comboboxes

in combobox1 i am retrieving the data from one master table(say aaaa) ,where shortform is the name of the column

Private Sub ComboBox1_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.DropDown

ComboBox1.DisplayMember = "shortform"
ds1.Clear()
da1.Fill(ds1, "p")
ComboBox1.DataSource = ds1.Tables("p")

End Sub



in combobox2, i am retrieving the data from another master table called bankdet.

Private Sub ComboBox2_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox2.DropDown

ComboBox2.DisplayMember = "bankname"
ComboBox2.DataSource = DataSet11.bankdet
ds.Clear()
da2.Fill(ds, "b")
ComboBox2.DataSource = ds.Tables("b")

End Sub

similarly i am using third master table in combobox3

Private Sub ComboBox3_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox3.DropDown

ComboBox3.DisplayMember = "Division"
ds1.Clear()
da11.Fill(ds1, "d")
ComboBox3.DataSource = ds1.Tables("d")

End Sub


similarly fourth master table in combobox4

Private Sub ComboBox4_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox4.DropDown

ComboBox4.DisplayMember = "region"
ds1.Clear()
da12.Fill(ds1, "r")
ComboBox4.DataSource = ds1.Tables("r")

End Sub

my error is when i am selecting first combobox then the data is retrieved from the master table.
and when i select second combobox ,then the data in the first combobox is lost

so what so i do to remain the data in the comboboxes when i select the next combobox
thanks
 
Well, you shouldn't be populating the combo on it's drop down.... they should already be filled.

Secondly, I notice in ComboBoxes 3 & 4, you keep clearing ds1.... this is going to cause combobox1 to clear itself as well.

There should be one DS, with four tables in it, each with a different name. Each one of those should then be set as the datasource of their respective combobox. And this should be done in another location other than the drop down (this may explain the error).

Tg
 
your code looks funny.

try filling all tabled in one dataset and don't use clear function.

You have four tables and you need to fill combos with them. Try this:

da1.Fill(ds, "Table1")
combo1.DataSource = ds
combo1.DataMember = "Table1"
combo1.ValueMember = "Column1"
combo1.DisplayMember = "Column2"

da2.Fill(ds, "Table2")
combo2.DataSource = ds
combo2.DataMember = "Table2"
combo2.ValueMember = "Column1"
combo2.DisplayMember = "Column2"

... and so on
 
Back
Top