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#
  4. How to load data from db to combobox?

How to load data from db to combobox?

Scheduled Pinned Locked Moved C#
csharpquestionlearningasp-netdatabase
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.
  • M Offline
    M Offline
    misCafe
    wrote on last edited by
    #1

    Dear, I start programming a very small project called "CD Collection" for my self learning which is using C Sharp 2005 and MS Access 2007. I would love you to instruct me if possible. I can insert into table (eg: tbl_user (uID, username)) normally but I've no idea how to load these data to combobox (in other form - tbl_cd (cd_id, music_code, uID, cd_set_id)). So, what do I've to code? 1. How to load data from db to combobox? 2. After successfully loaded, I want to know how do I insert uID(from combobox) back to uID in tbl_cd? Many thanks,

    Chuon Visoth Angkor Wat - Cambodia asp.net - c sharp beginner

    C 1 Reply Last reply
    0
    • M misCafe

      Dear, I start programming a very small project called "CD Collection" for my self learning which is using C Sharp 2005 and MS Access 2007. I would love you to instruct me if possible. I can insert into table (eg: tbl_user (uID, username)) normally but I've no idea how to load these data to combobox (in other form - tbl_cd (cd_id, music_code, uID, cd_set_id)). So, what do I've to code? 1. How to load data from db to combobox? 2. After successfully loaded, I want to know how do I insert uID(from combobox) back to uID in tbl_cd? Many thanks,

      Chuon Visoth Angkor Wat - Cambodia asp.net - c sharp beginner

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      If you set the datasource of the combobox to be the dataset you get back from the DB, you set the displaymember property to set which column the combobox should show.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      M 1 Reply Last reply
      0
      • C Christian Graus

        If you set the datasource of the combobox to be the dataset you get back from the DB, you set the displaymember property to set which column the combobox should show.

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        M Offline
        M Offline
        misCafe
        wrote on last edited by
        #3

        Would you mind to give me a code? Yours,

        Chuon Visoth Angkor Wat - Cambodia asp.net - c sharp beginner

        T 1 Reply Last reply
        0
        • M misCafe

          Would you mind to give me a code? Yours,

          Chuon Visoth Angkor Wat - Cambodia asp.net - c sharp beginner

          T Offline
          T Offline
          tamir101
          wrote on last edited by
          #4

          From The NorthWind DB: //Create DataSet Member DataSet ds = new DataSet(); //Fill The DataSet With Data: //CustomersAndOrders - Function that returns DataSet (one DataTable Of Customers and one Of Orders. ds = empLogic.CustomersAndOrders(); //Show The Table Source cmbCustomers.DataSource = ds.Tables["Customes"]; //Witch Culomn We Want To Show cmbCustomers.DisplayMember = "CompanyName"; //Save The CustomerID Key For Future Use cmbCustomers.ValueMember = "CustomerID";

          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