Combobox and dataset

Cmr

Member
Joined
May 16, 2006
Messages
17
Programming Experience
1-3
Hello,
I am having three comboboxes from where I have to choose three different datas.
I have used the following method and it works well.
To reduce my coding I used only one dataset DS and set it as datasource for all three comboboxes. When I tried this way, if a choose a data field say record 1 for one combobox, the datafield for the rest of the two gets automatically changed to record 1.

So if I have to choose one data set where should I modify.

Thanks
VB.NET:
CMR
myCon = New SqlConnection("server=ABC;Trusted_Connection=yes;database=BankDetails")
myAda = New SqlDataAdapter("Select Convert(varchar(20),pid)+space(2)+ name as col1 from CustomerDetails", myCon)
 
myAda.Fill(DS, "customerdetails")
myAda.Fill(DS1, "customerdetails")
myAda.Fill(DS2, "customerdetails")
cbFHOLDER.DataSource = DS.Tables("CustomerDetails")
cbSHOLDER.DataSource = DS1.Tables("CustomerDetails")
cbNOMINEE.DataSource = DS2.Tables("CustomerDetails")
cbFHOLDER.DisplayMember = "col1"
cbSHOLDER.DisplayMember = "col1"
cbNOMINEE.DisplayMember = "col1"
 
Last edited by a moderator:
Not sure whether this is what you want

VB.NET:
myAda.Fill(DS, "customerdetails")
 
[SIZE=2][/SIZE][SIZE=2]Dim dvList1 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] DataView = new DataView(DS.Tables("customerdetails"))
[/SIZE][SIZE=2][SIZE=2]Dim dvList2 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] DataView = new DataView(DS.Tables("customerdetails"))
[/SIZE]Dim dvList3 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] DataView = new DataView(DS.Tables("customerdetails"))
[/SIZE]
cbFHOLDER.DataSource = dvList1 
cbSHOLDER.DataSource = dvList2 
cbNOMINEE.DataSource = dvList3 
cbFHOLDER.DisplayMember = "col1"
cbSHOLDER.DisplayMember = "col1"
cbNOMINEE.DisplayMember = "col1"
 
Lingsn,

Thanks for the reply.
I pasted your coding. unfortunately nothing got displayed in the combobox.

In case you did not understand my query. I will explain it as precise as possible.

As mentioned in my code if I substitute DS1 and DS2 with DS(where DS,DS1,DS2 are datasets) I cannot choose different values in different comboboxes.

eg. There are three no. 1,2,3 which are displayed in all three comboboxes. When I use only one dataset say DS and connect all the three comboboxes to it, then when I choose no.1 in combobox1 ,rest of the two comboboxes gets set to no.1.
If I choose no.2 in any one of the combobox, the rest of the comboboxes sets the values to no.2 automatically.

So my question is can we avoid creation of three different datasets.

Do I make myself clear.

Kindly reply.
 
Back
Top