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. add an ID from an from an combobox in buttun click event

add an ID from an from an combobox in buttun click event

Scheduled Pinned Locked Moved Visual Basic
security
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.
  • Q Offline
    Q Offline
    Qendro
    wrote on last edited by
    #1

    hello to everyone I'm trying to store an ID of a person from a table which is related to another so I wrote a peace of code that takes the names of persons from that table and expandes them on a combobox but when I click on a Save button it does not take the ID of a person to store it on a table which is related. Here is my code: Private Sub frmXhirojare_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim ds As New DataSet Dim conn As SqlConnection = New SqlConnection("Data Source=.;Initial Catalog=dbHyrjaXhirove;Integrated Security=True") Dim selection As String = "SELECT PartneriID, Emri FROM tblPartneret" Dim dataadapteri As SqlDataAdapter = New SqlDataAdapter(selection, conn) dataadapteri.MissingSchemaAction = MissingSchemaAction.AddWithKey dataadapteri.Fill(ds, "tblXhiro") ComboBox1.DataSource = ds.Tables("tblXhiro") ComboBox1.ValueMember = "PartneriID" ComboBox1.DisplayMember = "Emri" End Sub I would be thankful to everyone who takes a minute from his time to explain it to me why when I click to the Save button it does not take the PartneriID in this case and store it on related table.

    Qendro

    S 1 Reply Last reply
    0
    • Q Qendro

      hello to everyone I'm trying to store an ID of a person from a table which is related to another so I wrote a peace of code that takes the names of persons from that table and expandes them on a combobox but when I click on a Save button it does not take the ID of a person to store it on a table which is related. Here is my code: Private Sub frmXhirojare_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim ds As New DataSet Dim conn As SqlConnection = New SqlConnection("Data Source=.;Initial Catalog=dbHyrjaXhirove;Integrated Security=True") Dim selection As String = "SELECT PartneriID, Emri FROM tblPartneret" Dim dataadapteri As SqlDataAdapter = New SqlDataAdapter(selection, conn) dataadapteri.MissingSchemaAction = MissingSchemaAction.AddWithKey dataadapteri.Fill(ds, "tblXhiro") ComboBox1.DataSource = ds.Tables("tblXhiro") ComboBox1.ValueMember = "PartneriID" ComboBox1.DisplayMember = "Emri" End Sub I would be thankful to everyone who takes a minute from his time to explain it to me why when I click to the Save button it does not take the PartneriID in this case and store it on related table.

      Qendro

      S Offline
      S Offline
      Steven J Jowett
      wrote on last edited by
      #2

      ComboBox1.Value should contain the person Id.

      Steve Jowett ------------------------- Real programmers don't comment their code. If it was hard to write, it should be hard to read.

      Q 1 Reply Last reply
      0
      • S Steven J Jowett

        ComboBox1.Value should contain the person Id.

        Steve Jowett ------------------------- Real programmers don't comment their code. If it was hard to write, it should be hard to read.

        Q Offline
        Q Offline
        Qendro
        wrote on last edited by
        #3

        Could You be more specific and tell me where to write Combobox1.Value because in my code I wrote Combobox1.ValueMember = "PartneriID" which I think is the appropriate thing in this case.My problem is that when I click on the Save button it saves all the values through the parameters exept the PersoniID which is represeted by this combobox. Thank You for your reply and I would be thankful if You put me in a correct road with this problem. :)

        Qendro

        C 1 Reply Last reply
        0
        • Q Qendro

          Could You be more specific and tell me where to write Combobox1.Value because in my code I wrote Combobox1.ValueMember = "PartneriID" which I think is the appropriate thing in this case.My problem is that when I click on the Save button it saves all the values through the parameters exept the PersoniID which is represeted by this combobox. Thank You for your reply and I would be thankful if You put me in a correct road with this problem. :)

          Qendro

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

          ValueMember sets where to get the value from. Value is the value that was set. I think you need to do some reading on VB.NET, this is pretty straightforward stuff.

          Christian Graus Driven to the arms of OSX by Vista.

          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