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. Visual Basic
  4. populate dropdownlist

populate dropdownlist

Scheduled Pinned Locked Moved Visual Basic
databasequestion
4 Posts 4 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
    Manik Nath
    wrote on last edited by
    #1

    hi ppl, i have a database with three columns namely first_name, second_name and third_name. and i want only the contents of first column i.e contents of first_name column to be displayed in a dropdownlist how do i do this. thanks and regards

    S C L 3 Replies Last reply
    0
    • M Manik Nath

      hi ppl, i have a database with three columns namely first_name, second_name and third_name. and i want only the contents of first column i.e contents of first_name column to be displayed in a dropdownlist how do i do this. thanks and regards

      S Offline
      S Offline
      syed saba
      wrote on last edited by
      #2

      by using the following code u will be able to add data from first_name: dim Cn as new adodb.connection dim rs as new adodb.recordset dim str as string cn.Open "DSN-NAME", "UID", "PWD" Set rS.ActiveConnection = cn str_State = "Select DISTINCT FIELD-NAME from TABLE-NAME" rs.Open str, cn, adOpenStatic, adLockReadOnly For j = 1 To rs.RecordCount cmbo1.AddItem rs.Fields(0).Value rs.MoveNext Next If rs.State = 1 Then rs.Close Set rs = Nothing End If If cn.State = 1 Then cn.Close Set cn = Nothing End If

      1 Reply Last reply
      0
      • M Manik Nath

        hi ppl, i have a database with three columns namely first_name, second_name and third_name. and i want only the contents of first column i.e contents of first_name column to be displayed in a dropdownlist how do i do this. thanks and regards

        C Offline
        C Offline
        CalaLily
        wrote on last edited by
        #3

        Populate a dataset with data from the table containing the first_name columns.Then set the following properties of the combo-box(dropdown):- ComboBox1.datasource = name-of-dataset.Tables(0) ComboBox1.DisplayMember = "first_name" ComboBox1.ValueMember = "first_name"

        1 Reply Last reply
        0
        • M Manik Nath

          hi ppl, i have a database with three columns namely first_name, second_name and third_name. and i want only the contents of first column i.e contents of first_name column to be displayed in a dropdownlist how do i do this. thanks and regards

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          You can do it at run time by using code Private myRow As DataRow Private myCol As DataColumn Private myTable As DataTable myCol = myTable.Columns(0) For Each myRow In myTable.Rows ComboSample.Items.Add(myRow(0)) Next or simply use comboBox1.DataSource=dataSet where dataset contains the required table. Lata Agrawal

          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