C# combobox 数据绑定

OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\\Documents and Settings\\Administrator\\My Documents\\Success.mdb;");
            DataSet myDatset = new DataSet();
            string comanderStr = "select * from 行政区划";
            conn.Open();
            OleDbDataAdapter myAdpt = new OleDbDataAdapter(comanderStr, conn);
            myAdpt.Fill(myDatset,"行政区划");
            所属村comboBox.DataSource = myDatset;
            所属村comboBox.DisplayMember = "行政区划.fname";
            所属村comboBox.ValueMember = "行政区划.fname";
            conn.Close();

posted @ 2012-07-17 15:48  美丽的矩阵  阅读(234)  评论(0编辑  收藏  举报