Hi all,
heres my code

Dim con As New MySqlConnection("server=localhost; user id=root; password=phoenix0931; database=accounts;")
        Try
            con.Open()
            Dim dat As MySqlDataAdapter = New MySqlDataAdapter("SELECT customers_id,customer_name,customer_add FROM customers ", con)
            Dim dt As New DataSet
            dat.Fill(dt, "customers")
            ComboBox1.DataSource = dt.Tables("customers").DefaultView
            ComboBox1.DisplayMember = "customer_name"
            ComboBox1.ValueMember = "customers_id"

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            con.Close()
        End Try

my Problem what code will i add if im going to display my customer_add in my textbox2
match on the record that i pick in the combo box..

Use dataview object and filter the dataview object based on the selected value in combobox and assign that value to textbox.

Can you lend me some code sir?? please? i try many codes but i did not succeed

Dim dv As New DataView
            dv = ds.Tables(0).DefaultView
            dv.RowFilter = "Ur Expression to filter the row"

sir
i try these code but i dont know what code is missing in this code ?
can you fix it?

Protected Const strConnPubs As String = "server=localhost; user id=root; password=phoenix0931; database=accounts;"
    Protected strPubsCMD As String = "select customers_id, customer_name from customers"

    Protected dvName As DataView
    Protected dsName As New DataSet()

        
    Private Sub Form8_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        loadcus()

        




    End Sub

    Private Sub loadcus()

        Try

            Dim cnPubs As MySqlConnection = New MySqlConnection(strConnPubs)
            Dim PubsDA As New MySqlDataAdapter(strPubsCMD, cnPubs)

            PubsDA.Fill(dsName, "customers")

            dvName = New DataView(dsName.Tables("customers"), "", "customers_id", DataViewRowState.OriginalRows)


            With ComboBox1
                .ValueMember = "customers_id"
                .DisplayMember = "customer_name"
                .DataSource = dvName
            End With

            ComboBox1.SelectedIndex = -1

            cnPubs.Dispose()
            PubsDA.Dispose()

        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, Me.Text)

        End Try
    End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        TextBox2.Text = ComboBox1.SelectedIndex.ToString
    End Sub

i dont know what code to put to show in the textbox2 the exact value of what i picked in my combo box base on my database record..

ex.
i pick in my combo box "Erick"
the textbox2 must be " Juan"

Have the Dv in form level variable or else in selectedindexchanged event of combobox load the records again and do the rowfilter on dataview and assign the value to textbox..

sir can you give the code? dont know where to start.

In combobox Selectedindexchanged event do the rowfilter on DV and dv will give you on row select the column you want to assign to textbox and assign it..

Try
            Dim x As String = ""
            x = ComboBox1.SelectedValue.ToString
            dv.RowFilter = "Customer= '" & "x " & "'"
            TextBox1.Text = dv.Table(0).Item(1).ToString
        Catch ex As Exception

        End Try

sir there's an error

" Class System.Data.Datatable" cannot be indexed because it has no default property

Where you got the error?
Can you debug code when Selected index changed of combo? is Dataset is loading properly? dv has any rows before filtering the records?

i cant debug ur code from here...:)

sir can you see? the image that i've post? thats what happening when i run it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.