0

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..

Attachments QShot_0001.jpg 88.33 KB
2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by P.manidas
0

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()
0

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..

Edited by arezz09: n/a

0

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
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.