c# - duplicity in combo-box when i fill -


I have this code to fill the combo box

  sql = "select difference name , "MyTbl Order Number" by name; Adp = New OracleDataAdapter (SQL, Conn); APP file (dsna, "methball"); adp.Dispose (); ComFna.DataSource = dsNa.Tables [0]; ComFna. DisplayMember = dsNa.Tables [0] .column [0] .columnName; ComFna.ValueMember = DSNA.Tables [0] .column [1] .claimname;  

but to enter a new name Afterwards - I do not see the hem

And then I run this code again - I see fake records

How to solve it? (I work on C # Winform)

Thank you in advance

When you add a new database, you have two options: 1) Create a new item (and num value) with the given name and Put it in the combobox item collection. 2) Reboot combobox (which you are using) from the database

The only problem is that you need to clean the combobox item Mr. Prior to need or re-bind it needs to clear its data source.

  adp.Dispose (); ComFna.DataSource = null; // Add this line here or comFna.Items.Clear (); ComFna.DataSource = dsNa.Tables [0]; ComFna.DisplayMember = dsNa.Tables [0] Column [0]. Column name; ComFna.ValueMember = DSNA Tables [0]. Column [1]. Column name;  

Comments