Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

remove database duplicate value

$
0
0

Dear All,

how to remove the duplicate value when its select  item from the database. this code is working fine but its show duplicate value in the combobo.

like: gold, gold, gold, silver, silver

its show 3 and 2 times in the combobox. so how to remove this error.

it is show only one - one times.

private void cmboItemType()    //for combobox
        {
            string connstr = @"Server=.\SQLEXPRESS ;Initial Catalog=RPSJDB;Integrated Security=True; Max Pool Size=100";
            SqlConnection conn = new SqlConnection(connstr);

            SqlCommand cmd = new SqlCommand("SELECT cmbItemType FROM ItemTable", conn);
            conn.Open();
            SqlDataReader sdr = cmd.ExecuteReader();
            ArrayList ItemStore = new ArrayList();
            while (sdr.Read())
            {
                ItemStore.Add(new AddValue(sdr.GetString(0)));
            }
            sdr.Close();
            conn.Close();
            cmbItemType.DataSource = ItemStore;
            cmbItemType.DisplayMember = "Display";
        }

        public class AddValue
        {
            private string Displaym;
         
            public AddValue(string Display)
            {
                Displaym = Display;
            }
            public string Display
            {
                get { return Displaym; }
            }
        }


Viewing all articles
Browse latest Browse all 3509

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>