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. Three tables, 3 Combobox in a single form, HELP! [modified]

Three tables, 3 Combobox in a single form, HELP! [modified]

Scheduled Pinned Locked Moved Visual Basic
databasehelpquestion
7 Posts 2 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.
  • A Offline
    A Offline
    abbasy
    wrote on last edited by
    #1

    Hi, In 1 form i put 3 combobox that the data fillout from 3 tables sql database, i'm using DataAdapter, Dataset (as usual) to bind the field from table1 to Combobox1, i got no problem with that, but when i want to bind the second table to second combobox and the third table to the third combobox are not succeded, the value in the other combo is the same with the first combo, how do i set it up properly?:confused: Abbas -- modified at 6:11 Wednesday 12th July, 2006

    F 1 Reply Last reply
    0
    • A abbasy

      Hi, In 1 form i put 3 combobox that the data fillout from 3 tables sql database, i'm using DataAdapter, Dataset (as usual) to bind the field from table1 to Combobox1, i got no problem with that, but when i want to bind the second table to second combobox and the third table to the third combobox are not succeded, the value in the other combo is the same with the first combo, how do i set it up properly?:confused: Abbas -- modified at 6:11 Wednesday 12th July, 2006

      F Offline
      F Offline
      fredde_d
      wrote on last edited by
      #2

      When you say "bind the second table to second combobox and the third table to the third combobox"... Are using three different DataAdapters and three different DataSets?

      A 1 Reply Last reply
      0
      • F fredde_d

        When you say "bind the second table to second combobox and the third table to the third combobox"... Are using three different DataAdapters and three different DataSets?

        A Offline
        A Offline
        abbasy
        wrote on last edited by
        #3

        Yes i did, three adapter, three dataset, three sql command, all of that in one event, form_load event, is it someting to do with the event? Abbas

        F 1 Reply Last reply
        0
        • A abbasy

          Yes i did, three adapter, three dataset, three sql command, all of that in one event, form_load event, is it someting to do with the event? Abbas

          F Offline
          F Offline
          fredde_d
          wrote on last edited by
          #4

          Interesting... Can you email me the code or post it here and I'll take a look at it?

          A 1 Reply Last reply
          0
          • F fredde_d

            Interesting... Can you email me the code or post it here and I'll take a look at it?

            A Offline
            A Offline
            abbasy
            wrote on last edited by
            #5

            I'm sorry, now is ok, i just miss type the objname of each data adapter and dataset, now is ok, but i have another question I already bind the column from table to combobox, and succesfull, but i need to add an empty row, so when the form run the combobox is empty but when i select it will show the empty row and the fields, the result is like this 'objComboBox1 " " 'empty field "Field 1" 'come from table "Field 2" 'come from table "Field 3" 'come from table "Field 4" 'come from table etc Here are the Code that i use Dim objConn As New SqlConnection Dim objDS As New DataSet Dim objDA As New SqlDataAdapter Dim objCM As New SqlCommand objConn.ConnectionString = "" Try objConn.Open() Catch ex As Exception MsgBox(ex.Message) Exit Sub End Try objCM = New SqlCommand("Select Name_VC from tPersonnel_TB Order by Name_VC", objConn) objDA.SelectCommand = objCM objDA.Fill(objDS, "Personnel") CBPersonnel.DataSource = objDS.Tables("Personnel") CBPersonnel.DisplayMember = "Name_VC" Thnx Abbas -- modified at 6:33 Thursday 13th July, 2006

            F 1 Reply Last reply
            0
            • A abbasy

              I'm sorry, now is ok, i just miss type the objname of each data adapter and dataset, now is ok, but i have another question I already bind the column from table to combobox, and succesfull, but i need to add an empty row, so when the form run the combobox is empty but when i select it will show the empty row and the fields, the result is like this 'objComboBox1 " " 'empty field "Field 1" 'come from table "Field 2" 'come from table "Field 3" 'come from table "Field 4" 'come from table etc Here are the Code that i use Dim objConn As New SqlConnection Dim objDS As New DataSet Dim objDA As New SqlDataAdapter Dim objCM As New SqlCommand objConn.ConnectionString = "" Try objConn.Open() Catch ex As Exception MsgBox(ex.Message) Exit Sub End Try objCM = New SqlCommand("Select Name_VC from tPersonnel_TB Order by Name_VC", objConn) objDA.SelectCommand = objCM objDA.Fill(objDS, "Personnel") CBPersonnel.DataSource = objDS.Tables("Personnel") CBPersonnel.DisplayMember = "Name_VC" Thnx Abbas -- modified at 6:33 Thursday 13th July, 2006

              F Offline
              F Offline
              fredde_d
              wrote on last edited by
              #6

              I know there is a way to specify that any items in the combobox should not be removed during binding. I did this in an asp.net app not long ago but I dont have access to the code at the moment... Basicly you add the empty string to the combo set the (at the moment unknown) property not to clear the combo and then you do the databinding. Workaround: Do the databinding and then: CBPersonnel.Items.Insert(0,"") BR Fredrik

              A 1 Reply Last reply
              0
              • F fredde_d

                I know there is a way to specify that any items in the combobox should not be removed during binding. I did this in an asp.net app not long ago but I dont have access to the code at the moment... Basicly you add the empty string to the combo set the (at the moment unknown) property not to clear the combo and then you do the databinding. Workaround: Do the databinding and then: CBPersonnel.Items.Insert(0,"") BR Fredrik

                A Offline
                A Offline
                abbasy
                wrote on last edited by
                #7

                I just do what you said, if i put after the data binding it show an error but if i put before binding the data the form is running ok but nothing happens the data is still the same is there anyway else to do that? Abbas

                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