locked
DataBindings - Textbox and Label (not binding as expected ) RRS feed

All replies

  • Hi Expert,

    This is my code, combo box is working find. thanks for the help.

    Private Sub TextBox5_TextChanged(sender As Object, e As EventArgs) Handles TextBox5.TextChanged
            Try
                Dim table1 As New DataTable
                Dim SDA1 As New SqlDataAdapter
                Dim bSource1 As New BindingSource

                connection.Open()
                Dim query As String
                Dim ds1 As DataSet = New DataSet
                query = "select* from SAPCONSUMABLE WHERE Description LIKE '%" & TextBox5.Text & "%'"
                command = New SqlCommand(query, connection)
                SDA1.SelectCommand = command
                SDA1.Fill(ds1, "SAPCONSUMABLE")
                bSource1.DataSource = table1
                ComboBox3.DataSource = ds1.Tables("SAPCONSUMABLE")
                ComboBox2.DataSource = ds1.Tables("SAPCONSUMABLE")
                ComboBox4.DataSource = ds1.Tables("SAPCONSUMABLE")
                ComboBox5.DataSource = ds1.Tables("SAPCONSUMABLE")

                SDA1.Update(table1)

                connection.Close()

            Catch ex As SqlException
                MessageBox.Show(ex.ToString)
            End Try

        End Sub

    Thursday, August 2, 2018 12:13 AM
  • Are you indicating your issue is resolved?

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, August 2, 2018 12:26 AM
  • Yes, thanks god it works now I made some change with the control from textbox into combobox and change the property into simple and bound to the binding source. I made the change code as follows:

    Everything working fine, and when I make a search the item, the data is updated from my backend.

      Try
                Dim table1 As New DataTable
                Dim SDA1 As New SqlDataAdapter
                Dim bSource1 As New BindingSource

                connection.Open()
                Dim query As String
                Dim ds1 As DataSet = New DataSet
                query = "select* from SAPCONSUMABLE WHERE Description LIKE '%" & TextBox5.Text & "%'"
                command = New SqlCommand(query, connection)
                SDA1.SelectCommand = command
                SDA1.Fill(ds1, "SAPCONSUMABLE")

                ComboBox3.DataSource = ds1.Tables("SAPCONSUMABLE")
                ComboBox2.DataSource = ds1.Tables("SAPCONSUMABLE")
                ComboBox4.DataSource = ds1.Tables("SAPCONSUMABLE")
                ComboBox5.DataSource = ds1.Tables("SAPCONSUMABLE")
                ComboBox6.DataSource = ds1.Tables("SAPCONSUMABLE")
                ComboBox7.DataSource = ds1.Tables("SAPCONSUMABLE")
                ComboBox8.DataSource = ds1.Tables("SAPCONSUMABLE")
                ComboBox9.DataSource = ds1.Tables("SAPCONSUMABLE")



                SDA1.Update(table1)

                connection.Close()

            Catch ex As SqlException
                MessageBox.Show(ex.ToString)
            End Try


            connection.Close()

    • Proposed as answer by Alex-KSGZ Thursday, August 9, 2018 2:10 AM
    Thursday, August 2, 2018 12:46 AM
  • Please mark your reply as answered then.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, August 2, 2018 1:06 AM
  • Hi 

    I am glad you have got your solution, we appreciated you shared us your solution, we also hope you can mark it as an answer.By marking a post as Answered or Helpful, you help others find the answer faster.

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, August 2, 2018 1:09 AM
  • How is it working without a DisplayMember, or ValueMember?

    Live as if you were going to die today, learn as if you were going to live forever -Mahatma Gandhi

    Thursday, August 2, 2018 12:17 PM
  • Hi

    Does this meet your requirements?

     For Each dv In dt.Rows
                    ComboBox1.Items.Add(dv("ColumnName").ToString)
                Next

    Best regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, August 3, 2018 2:05 AM
  • No extra coding, just I remove the textbox and label , and then I use combox and make simple property. And then bound on it. It works very fine. the moment I search the item it will automatically populate the the combo box. 
    Friday, August 3, 2018 4:21 AM