天天看点

ComboBox绑定数据库内容

1.轮询添加数据库内容 

DataTable dbaoz1 = this.dClass.GetDataTable("select item from Rx_xxiang where mingchen = 'baoz'");

            for (int i = 0; i < dbaoz1.Rows.Count; i++)

            {

                this.baoz1.Items.Add(dbaoz1.Rows[i][0].ToString());

            }

2.绑定数据库内容

DataTable sate = this.dClass.GetDataTable(string.Concat(new object[] { "SELECT  cSTCode, cSTName FROM ", cAcc_Name, ".dbo.SaleType" }));

            if (sate.Rows.Count > 0)

            {

                this.cstcode.DataSource = sate;

                this.cstcode.DisplayMember = "cSTName";

                this.cstcode.ValueMember = "cSTCode";

                //this.rsyse1.Text = "";

                //this.gongyi.SelectedValue.tostring

            }