日期:2014-05-17 浏览次数:20870 次
private void BindCategory()
{
string sql = ReportForm.Properties.Settings.Default.CEC710ConnectionString;
SqlConnection conn = new SqlConnection(sql);
DataSet1 myData = new DataSet1();
SqlDataAdapter da = null;
da = new SqlDataAdapter("select b.name from BuildNumber a inner join Category b on a.BNumber = b.BNumber where a.Description = '" + comboBox1.SelectedValue + "'", conn);
da.Fill(myData, "Category");
this.comboBox3.DataSource = myData;
this.comboBox3.DisplayMember = myData.Tables[0].Columns[2].ColumnName;
this.comboBox3.ValueMember = myData.Tables[0].Columns[2].ColumnName;
}
this.comboBox3.DataSource = myDataTables[0]; this.comboBox3.DisplayMember = myData.Tables[0].Columns[2].ColumnName; this.comboBox3.ValueMember = myData.Tables[0].Columns[2].ColumnName;
------解决方案--------------------
private void BindCategory()
{
string sql = ReportForm.Properties.Settings.Default.CEC710ConnectionString;
SqlConnection conn = new SqlConnection(sql);
DataSet1 myData = new DataSet1();
SqlDataAdapter da = null;
da = new SqlDataAdapter("select b.name as CategoryName from BuildNumber a inner join Category b on a.BNumber = b.BNumber where a.Description = '" + comboBox1.SelectedValue + "'", conn);
da.Fill(myData, "Category");
this.comboBox3.DataSource = myData;
this.comboBox3.DisplayMember = myData.Tables[0].Columns[2].ColumnName;
this.comboBox3.ValueMember = myData.Tables[0].Columns[2].ColumnName;
}
this.comboBox3.DataSource = myData.Tables[0];
this.comboBox3.DisplayMember = "CategoryName";
this.comboBox3.ValueMember = "CategoryName";