how to fill a combobox with datatadapter
-
I want fill a combobox with a dataadapter, can i do that in vc++ and how i do that? (in vb or c# is possible!) there are some others way? i want a key and a value for all the item of the combobox. thanks a lot
What do you mean by data adapter ? You can populate combobox easily and set their data by: i = CComboBox::AddString( "your string" ); // function returns index of item CComboBox::SetItemData( i, int_key_value ); // set the data then retrieving the selected item: i = CComboBox::GetCurSel(); // returns index of selected item v = CComboBox::GetItemData( i ); // returns item's data
-
What do you mean by data adapter ? You can populate combobox easily and set their data by: i = CComboBox::AddString( "your string" ); // function returns index of item CComboBox::SetItemData( i, int_key_value ); // set the data then retrieving the selected item: i = CComboBox::GetCurSel(); // returns index of selected item v = CComboBox::GetItemData( i ); // returns item's data
for examples with c# we can do somethings like this: string sqlStr ="SELECT * FROM studentTable;"; dAdapter = new OleDbDataAdapter(sqlStr,myConn); dset = new DataSet(); dAdapter.TableMappings.Add("Table","studentTable"); dAdapter.Fill(dset); DataSet.DefaultViewManager property this.dviewmanager=dset.DefaultViewManager; this.comboBox1.DataSource=this.dviewmanager; this.comboBox1.DisplayMember="studentTable.StudentID"; i want to do the same things with vc++ .net its possilbe? thanks
-
for examples with c# we can do somethings like this: string sqlStr ="SELECT * FROM studentTable;"; dAdapter = new OleDbDataAdapter(sqlStr,myConn); dset = new DataSet(); dAdapter.TableMappings.Add("Table","studentTable"); dAdapter.Fill(dset); DataSet.DefaultViewManager property this.dviewmanager=dset.DefaultViewManager; this.comboBox1.DataSource=this.dviewmanager; this.comboBox1.DisplayMember="studentTable.StudentID"; i want to do the same things with vc++ .net its possilbe? thanks
Whoa thats some Sql database access (i dont know those), I cant help you with that, maybe if you look at CDaoDatabase, you can access databases with it. But IMHO you have to get records from database and set them to the combo box one by one, there is probably not such command.