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 Studio
  4. Is this the perfect code to retrieve data from table to combobox?

Is this the perfect code to retrieve data from table to combobox?

Scheduled Pinned Locked Moved Visual Studio
question
3 Posts 2 Posters 2 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.
  • V Offline
    V Offline
    VSLearner2013
    wrote on last edited by
    #1

    Is the following code correct to load table field data to ComboBox? It is working fine but would like to know whether it is the perfect one.

    Public Function cboLoadPlants()
    Dim dt As DataTable = DAL.LoadData("SELECT DISTINCT Trim(Company) As [Company] FROM CompaniesTable").Tables(0)
    cboCompany.ValueMember = "Company"
    cboCompany.DataSource = dt
    cboCompany.SelectedIndex = 0
    Return True
    txtSearch.Select()
    End Function

    L 1 Reply Last reply
    0
    • V VSLearner2013

      Is the following code correct to load table field data to ComboBox? It is working fine but would like to know whether it is the perfect one.

      Public Function cboLoadPlants()
      Dim dt As DataTable = DAL.LoadData("SELECT DISTINCT Trim(Company) As [Company] FROM CompaniesTable").Tables(0)
      cboCompany.ValueMember = "Company"
      cboCompany.DataSource = dt
      cboCompany.SelectedIndex = 0
      Return True
      txtSearch.Select()
      End Function

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

      Please use the correct foruim[^]; this is not a Visual Studio issue.

      V 1 Reply Last reply
      0
      • L Lost User

        Please use the correct foruim[^]; this is not a Visual Studio issue.

        V Offline
        V Offline
        VSLearner2013
        wrote on last edited by
        #3

        Thanks. I will check it there.

        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