Three tables, 3 Combobox in a single form, HELP! [modified]
-
Hi, In 1 form i put 3 combobox that the data fillout from 3 tables sql database, i'm using DataAdapter, Dataset (as usual) to bind the field from table1 to Combobox1, i got no problem with that, but when i want to bind the second table to second combobox and the third table to the third combobox are not succeded, the value in the other combo is the same with the first combo, how do i set it up properly?:confused: Abbas -- modified at 6:11 Wednesday 12th July, 2006
-
Hi, In 1 form i put 3 combobox that the data fillout from 3 tables sql database, i'm using DataAdapter, Dataset (as usual) to bind the field from table1 to Combobox1, i got no problem with that, but when i want to bind the second table to second combobox and the third table to the third combobox are not succeded, the value in the other combo is the same with the first combo, how do i set it up properly?:confused: Abbas -- modified at 6:11 Wednesday 12th July, 2006
-
When you say "bind the second table to second combobox and the third table to the third combobox"... Are using three different DataAdapters and three different DataSets?
-
Yes i did, three adapter, three dataset, three sql command, all of that in one event, form_load event, is it someting to do with the event? Abbas
-
I'm sorry, now is ok, i just miss type the objname of each data adapter and dataset, now is ok, but i have another question I already bind the column from table to combobox, and succesfull, but i need to add an empty row, so when the form run the combobox is empty but when i select it will show the empty row and the fields, the result is like this 'objComboBox1 " " 'empty field "Field 1" 'come from table "Field 2" 'come from table "Field 3" 'come from table "Field 4" 'come from table etc Here are the Code that i use Dim objConn As New SqlConnection Dim objDS As New DataSet Dim objDA As New SqlDataAdapter Dim objCM As New SqlCommand objConn.ConnectionString = "" Try objConn.Open() Catch ex As Exception MsgBox(ex.Message) Exit Sub End Try objCM = New SqlCommand("Select Name_VC from tPersonnel_TB Order by Name_VC", objConn) objDA.SelectCommand = objCM objDA.Fill(objDS, "Personnel") CBPersonnel.DataSource = objDS.Tables("Personnel") CBPersonnel.DisplayMember = "Name_VC" Thnx Abbas -- modified at 6:33 Thursday 13th July, 2006
-
I'm sorry, now is ok, i just miss type the objname of each data adapter and dataset, now is ok, but i have another question I already bind the column from table to combobox, and succesfull, but i need to add an empty row, so when the form run the combobox is empty but when i select it will show the empty row and the fields, the result is like this 'objComboBox1 " " 'empty field "Field 1" 'come from table "Field 2" 'come from table "Field 3" 'come from table "Field 4" 'come from table etc Here are the Code that i use Dim objConn As New SqlConnection Dim objDS As New DataSet Dim objDA As New SqlDataAdapter Dim objCM As New SqlCommand objConn.ConnectionString = "" Try objConn.Open() Catch ex As Exception MsgBox(ex.Message) Exit Sub End Try objCM = New SqlCommand("Select Name_VC from tPersonnel_TB Order by Name_VC", objConn) objDA.SelectCommand = objCM objDA.Fill(objDS, "Personnel") CBPersonnel.DataSource = objDS.Tables("Personnel") CBPersonnel.DisplayMember = "Name_VC" Thnx Abbas -- modified at 6:33 Thursday 13th July, 2006
I know there is a way to specify that any items in the combobox should not be removed during binding. I did this in an asp.net app not long ago but I dont have access to the code at the moment... Basicly you add the empty string to the combo set the (at the moment unknown) property not to clear the combo and then you do the databinding. Workaround: Do the databinding and then: CBPersonnel.Items.Insert(0,"") BR Fredrik
-
I know there is a way to specify that any items in the combobox should not be removed during binding. I did this in an asp.net app not long ago but I dont have access to the code at the moment... Basicly you add the empty string to the combo set the (at the moment unknown) property not to clear the combo and then you do the databinding. Workaround: Do the databinding and then: CBPersonnel.Items.Insert(0,"") BR Fredrik