I dont know what code to put Here?

to get the exact value of my record on my database
here is my code

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


    End Sub

    Private Sub loadcus()


            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


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

        End Try
    End Sub

this is the code i use to get the address on textbox1

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

The problem is the textbox 1 displays only numbers not the address

Recommended Answers

All 5 Replies

Why are you doing selectedindex.tostring()???
its selecteditem.tostring()

Since your combobox is only populated with the customer_name and customer_id, these are the only items that you can load directly into the textbox. The syntax is comboBox1.SelectedItem.ToString and comboBox1.SelectedValue.ToString .
If you are trying to fill the textbox with the address of this customer, you must first find the address through an additional query. You can use comboBox1.SelectedValue to search the table according to customer_id to return the address.

hope this helps

Hi sir,
sorry for upsetting you up.
im doing this for almost 6hrs. and i cant solve it. Sorry for being brainless
im just a begineer , hope you understand :D

can you give me some code pls and then im going to review it to solve my problem pls

U have created the same thread twice dont do that.
have you tried what i pasted in the other thread???

how can i delete my previous thread?
yes im doing it? but i cannot succeed. im doing this for how many hours.

sir please can you fix my code and produce a comment line above it so i can pick it
up. i just wanna finish my project but im stuck in these code.

If you dont mind sir.

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.