Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to fill a combobox with datatadapter

how to fill a combobox with datatadapter

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++tutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tiziacaia
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • T tiziacaia

      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

      M Offline
      M Offline
      mirex
      wrote on last edited by
      #2

      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

      T 1 Reply Last reply
      0
      • M mirex

        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

        T Offline
        T Offline
        tiziacaia
        wrote on last edited by
        #3

        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

        A 1 Reply Last reply
        0
        • T tiziacaia

          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

          A Offline
          A Offline
          Anonymous
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups