把数据库表的某一列的数据添加到comboBox中

       public void update_cardName()
        {
            string conStr = "server=(local);database=个人财务管理; Integrated security=true;";
            SqlConnection con = new SqlConnection(conStr);
            string sqlStr = "select 卡号尾数 ,银行卡名称 from 银行卡信息;";
            try
            {
                con.Open();
                DataSet ds1 = new DataSet();
                DataSet ds2 = new DataSet();
                SqlDataAdapter da = new SqlDataAdapter(sqlStr, con);
                da.Fill(ds1);
                da.Fill(ds2);
                comboBox1.DataSource = ds1.Tables[0].DefaultView;
                comboBox1.DisplayMember = "卡号尾数";
                comboBox2.DataSource = ds2.Tables[0].DefaultView;
                comboBox2.DisplayMember = "卡号尾数";
                con.Close();
            }
            catch (Exception ex11)
     

你可能感兴趣的:(C#开发,数据库,dataset,exception,string,security,database)