i using this code to load data from accessdatabase to 2 combobox

Dim cmd As OleDbCommand = New OleDbCommand("SELECT product,model FROM combo_table", conn)

        conn.Open()

        Dim sdr As OleDbDataReader = cmd.ExecuteReader

        While sdr.Read()

            old_product.Items.Add(sdr.Item("product").ToString)
            old_model.Items.Add(sdr.Item("model").ToString)

        End While

        conn.Close()

        conn = Nothing


use can see in this picture hve 2 button, Product Entry and New Product..when i insert new product "Khink "automaticly Stock entry will load new data from accessdabase, but problem is if i go to form Stock Entry, old product in combobox will be double..when i close that form, and open it again, product name "Khink" will be double 2 and samsung,hitachi will be triple..

Recommended Answers

All 3 Replies

You need to clear the data from both the combobox before loading and updating data of the combobox like this..

old_product.Items.clear()
old_model.Items.clear()

where should i put this code??

this code will clear combobox product & model when i open stock entry form...so will no data in combo box..

Already mentioned "before loading and updating"

old_product.Items.clear()
old_model.Items.clear()
 While sdr.Read()
     old_product.Items.Add(sdr.Item("product").ToString)
     old_model.Items.Add(sdr.Item("model").ToString)
End While
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.