示例#1
0
        private void LoadHotlines()
        {
            SqlConnection con = new SqlConnection(ConnectionString);

            con.Open();

            SqlCommand comRead = new SqlCommand("SELECT * FROM Hotlines", con);

            SqlDataReader DR = comRead.ExecuteReader();


            comboBox2.Items.Clear();

            while (DR.Read())
            {
                Hotlines HL = new Hotlines();
                HL.id   = (int)DR[0];
                HL.Name = DR[1].ToString();
                comboBox2.Items.Add(HL);
                comboBox2.DisplayMember = "Name";
            }
            con.Close();
        }