예제 #1
0
        public void cargarColor(ComboBox comboBox1)
        {
            comboBox1.ToString();
            CDConexion conexion = new CDConexion();
            DataTable  dt       = new DataTable();

            using (conexion.AbrirConexion())
            {
                string         query = "select * from coloresBuses order by color";
                SqlCommand     cmd   = new SqlCommand(query, conexion.AbrirConexion());
                SqlDataAdapter da    = new SqlDataAdapter(cmd);
                da.Fill(dt);
            }

            comboBox1.DisplayMember = "color";
            comboBox1.ValueMember   = "id";
            comboBox1.DataSource    = dt;
            conexion.CerrarConexion();
        }