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. Get Databack from combobox.

Get Databack from combobox.

Scheduled Pinned Locked Moved Visual Basic
databasequestion
5 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.
  • H Offline
    H Offline
    hmanhha
    wrote on last edited by
    #1

    Hi ALl. I populated combobox from DB. And now when user select the value, how can i get the ID back.Because the selectedindex id diffirent from the original ID. Thanks.

    Richard DeemingR M 2 Replies Last reply
    0
    • H hmanhha

      Hi ALl. I populated combobox from DB. And now when user select the value, how can i get the ID back.Because the selectedindex id diffirent from the original ID. Thanks.

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      Depending on what type of application you're developing, the SelectedValue should give you either the selected database ID, or a DataRowView containing the values loaded from the database. If it doesn't, then you've not set up the binding correctly. :)


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      • H hmanhha

        Hi ALl. I populated combobox from DB. And now when user select the value, how can i get the ID back.Because the selectedindex id diffirent from the original ID. Thanks.

        M Offline
        M Offline
        Member 8345599
        wrote on last edited by
        #3

        I just use comboboxname.text. It will be a text file. If you want to get something from the DB, forget the index and just use a sql statement "SELECT * FROM db WHERE value = '" & comboboxname.text & "'"

        D Richard DeemingR 2 Replies Last reply
        0
        • M Member 8345599

          I just use comboboxname.text. It will be a text file. If you want to get something from the DB, forget the index and just use a sql statement "SELECT * FROM db WHERE value = '" & comboboxname.text & "'"

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Use Value instead. Getting the ID from a table with millions of records is much quicker by ID than it is by searching for a string.

          Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
          Dave Kreskowiak

          1 Reply Last reply
          0
          • M Member 8345599

            I just use comboboxname.text. It will be a text file. If you want to get something from the DB, forget the index and just use a sql statement "SELECT * FROM db WHERE value = '" & comboboxname.text & "'"

            Richard DeemingR Offline
            Richard DeemingR Offline
            Richard Deeming
            wrote on last edited by
            #5

            Member 8345599 wrote:

            "SELECT * FROM db WHERE value = '" & comboboxname.text & "'"

            Looks like you've got some reading to do! Everything you wanted to know about SQL injection (but were afraid to ask) | Troy Hunt[^] How can I explain SQL injection without technical jargon? | Information Security Stack Exchange[^] Query Parameterization Cheat Sheet | OWASP[^]


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

            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