Problems in using single dataset in different VB FORMS
-
Hello! I have been using Datasets and DataAdapters by dragging and dropping on my form. Now I have created a public class and created a dataset by code and filled it wit a Dataadapter. Dataset contains one table "DEPARTMENT" with columns "D_ID" and "D_NAME". Dataset is filled and contains data but when in windows form i tried to bind a combobox to that table it creates problems. 1) dim ClassObj as new DSClass 2)CobmoBox1.datasource = ClassObj.Dataset1.Tables("DEPARTMENT") 3)CobmoBox1.DisplayMember = ????????????????????????? 4)CobmoBox1.DisplayMember = ????????????????????????? Lines 3,4 creates problems, Please guide me
as900197
-
Hello! I have been using Datasets and DataAdapters by dragging and dropping on my form. Now I have created a public class and created a dataset by code and filled it wit a Dataadapter. Dataset contains one table "DEPARTMENT" with columns "D_ID" and "D_NAME". Dataset is filled and contains data but when in windows form i tried to bind a combobox to that table it creates problems. 1) dim ClassObj as new DSClass 2)CobmoBox1.datasource = ClassObj.Dataset1.Tables("DEPARTMENT") 3)CobmoBox1.DisplayMember = ????????????????????????? 4)CobmoBox1.DisplayMember = ????????????????????????? Lines 3,4 creates problems, Please guide me
as900197
One should be DisplayMember (the column that you want displayed in your combo), the other should be ValueMember (the column that represents the data you want to store). For example, if you have a table with columns ID and Description, you could set your DisplayMember to 'ID' and your ValueMember to 'Description'. On your form, you will see the value in the Description displayed in your combo but you will actually store the corresponding ID when updating your DataSet. CobmoBox1.DisplayMember = "ID" CobmoBox1.ValueMember = "Description" Steve
-
One should be DisplayMember (the column that you want displayed in your combo), the other should be ValueMember (the column that represents the data you want to store). For example, if you have a table with columns ID and Description, you could set your DisplayMember to 'ID' and your ValueMember to 'Description'. On your form, you will see the value in the Description displayed in your combo but you will actually store the corresponding ID when updating your DataSet. CobmoBox1.DisplayMember = "ID" CobmoBox1.ValueMember = "Description" Steve
Thanks Steve! It was so little mistake and i get so depressed.... Thank you
as900197
-
Thanks Steve! It was so little mistake and i get so depressed.... Thank you
as900197
You are welcome. Upon reading my answer again, I actually got the values the wrong way round! You would normally have the DisplayMember = "Description" and the ValueMember = "ID". Steve