问题描述
DBDriverdb=newDBDriver();this.comLab.Items.Clear();this.comPlace.Items.Clear();DataSetds=newDataSet();SqlDataAdapterda=newSqlDataAdapter("SELECT*FROMT_Store_Lab",db.conn);da.Fill(ds);this.comLab.DataSource=ds.Tables[0].DefaultView;this.comLab.ValueMember="ID";this.comLab.DisplayMember="Lab_Name";为什么DisplayMember值可以绑定,而ValueMember为什么全是空值?
解决方案
解决方案二:
stringMyconStr="DataSource=.;InitialCatalog=test;UserID=sa;Password=123456";SqlConnectionMyconn=newSqlConnection(MyconStr);Myconn.Open();stringMySql="selectPeoNofromhuang";SqlDataAdapterMyAdapt=newSqlDataAdapter(MySql,Myconn);DataSetMydataSet=newDataSet();MyAdapt.Fill(MydataSet);comboBox1.DataSource=MydataSet.Tables[0];comboBox1.DisplayMember="PeoNo";comboBox1.ValueMember="PeoNo";
时间: 2024-10-23 02:23:47