主题:dataGridView显示数据的问题
[b]情况介绍:[/b]如图所示:我依次搜索“累计量”,“日产量”,“班产量”时,字段是增加的,“日产量”增加了“日期”一个字段,“班产量”增加了“日期和班次”两个字段.
[b]但问题是:[/b]为什么增加的字段是在后面增加?我本意是想增加的字段在最前面显示,我要显示的顺序可以从下面的查询语句中看出来!
[b]正常情况:[/b]我依次搜索“班产量”,“日产量”,“累计量”时,字段是减少的,这种情况是正常的。
以下是我查询和显示的代码,请高手指点:
switch (this.tryComboBox.Text)
{
case "班产量":
//==原始数据查询
string selstr_class = "Select 日期 as 日期, 班次 as 班次, 汽车级 as 汽车级, 建筑级 as 建筑级, 制镜级 as 制镜级, 协议品 as 协议品, 试产品 as 试产品, 混等品 as 混等品, 总计 as 总计 from dayPro ";
OleDbDataAdapter myAdapter_class = new OleDbDataAdapter(selstr_class + " where 日期 between '" + this.dateTimePicker1.Text + "'and '" + this.dateTimePicker2.Text + "'", conn);
DataSet myDataSet_class = new DataSet();
myAdapter_class.Fill(myDataSet_class);
this.showDGView.DefaultCellStyle.Format = "0.00";
this.showDGView.DataSource = myDataSet_class.Tables[0];
conn.Close();
break;
case "日产量":
//==日产量查询
string selstr_day = "Select 日期 as 日期, 汽车级之总计 as 汽车级, 建筑级之总计 as 建筑级, 制镜级之总计 as 制镜级, 协议品之总计 as 协议品, 试产品之总计 as 试产品, 混等品之总计 as 混等品, 总计之总计 as 总计 from 日产量查询 ";
OleDbDataAdapter myAdapter_day = new OleDbDataAdapter(selstr_day + " where 日期 between '" + this.dateTimePicker1.Text + "'and '" + this.dateTimePicker2.Text + "'", conn);
DataSet myDataSet_day = new DataSet();
myAdapter_day.Fill(myDataSet_day);
this.showDGView.DefaultCellStyle.Format = "0.00";
this.showDGView.DataSource = myDataSet_day.Tables[0];
conn.Close();
break;
case "累计量":
//==累计产量查询
string selstr_classAll = "Select Sum(汽车级之总计) as 汽车级, Sum(建筑级之总计) as 建筑级, Sum(制镜级之总计) as 制镜级, Sum(协议品之总计) as 协议品, Sum(试产品之总计) as 试产品, Sum(混等品之总计) as 混等品, Sum(总计之总计) as 总计 from 日产量查询 ";
OleDbDataAdapter myAdapter_classAll = new OleDbDataAdapter(selstr_classAll + " where 日期 between '" + this.dateTimePicker1.Text + "'and '" + this.dateTimePicker2.Text + "'", conn);
DataSet myDataSet_classAll = new DataSet();
myAdapter_classAll.Fill(myDataSet_classAll);
this.showDGView.DefaultCellStyle.Format = "0.00";
this.showDGView.DataSource = myDataSet_classAll.Tables[0];
conn.Close();
break;
}
[b]但问题是:[/b]为什么增加的字段是在后面增加?我本意是想增加的字段在最前面显示,我要显示的顺序可以从下面的查询语句中看出来!
[b]正常情况:[/b]我依次搜索“班产量”,“日产量”,“累计量”时,字段是减少的,这种情况是正常的。
以下是我查询和显示的代码,请高手指点:
switch (this.tryComboBox.Text)
{
case "班产量":
//==原始数据查询
string selstr_class = "Select 日期 as 日期, 班次 as 班次, 汽车级 as 汽车级, 建筑级 as 建筑级, 制镜级 as 制镜级, 协议品 as 协议品, 试产品 as 试产品, 混等品 as 混等品, 总计 as 总计 from dayPro ";
OleDbDataAdapter myAdapter_class = new OleDbDataAdapter(selstr_class + " where 日期 between '" + this.dateTimePicker1.Text + "'and '" + this.dateTimePicker2.Text + "'", conn);
DataSet myDataSet_class = new DataSet();
myAdapter_class.Fill(myDataSet_class);
this.showDGView.DefaultCellStyle.Format = "0.00";
this.showDGView.DataSource = myDataSet_class.Tables[0];
conn.Close();
break;
case "日产量":
//==日产量查询
string selstr_day = "Select 日期 as 日期, 汽车级之总计 as 汽车级, 建筑级之总计 as 建筑级, 制镜级之总计 as 制镜级, 协议品之总计 as 协议品, 试产品之总计 as 试产品, 混等品之总计 as 混等品, 总计之总计 as 总计 from 日产量查询 ";
OleDbDataAdapter myAdapter_day = new OleDbDataAdapter(selstr_day + " where 日期 between '" + this.dateTimePicker1.Text + "'and '" + this.dateTimePicker2.Text + "'", conn);
DataSet myDataSet_day = new DataSet();
myAdapter_day.Fill(myDataSet_day);
this.showDGView.DefaultCellStyle.Format = "0.00";
this.showDGView.DataSource = myDataSet_day.Tables[0];
conn.Close();
break;
case "累计量":
//==累计产量查询
string selstr_classAll = "Select Sum(汽车级之总计) as 汽车级, Sum(建筑级之总计) as 建筑级, Sum(制镜级之总计) as 制镜级, Sum(协议品之总计) as 协议品, Sum(试产品之总计) as 试产品, Sum(混等品之总计) as 混等品, Sum(总计之总计) as 总计 from 日产量查询 ";
OleDbDataAdapter myAdapter_classAll = new OleDbDataAdapter(selstr_classAll + " where 日期 between '" + this.dateTimePicker1.Text + "'and '" + this.dateTimePicker2.Text + "'", conn);
DataSet myDataSet_classAll = new DataSet();
myAdapter_classAll.Fill(myDataSet_classAll);
this.showDGView.DefaultCellStyle.Format = "0.00";
this.showDGView.DataSource = myDataSet_classAll.Tables[0];
conn.Close();
break;
}