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; } } }
SELECT DISTINCT cmbItemType FROM ItemTable
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)