日期:2014-05-18  浏览次数:20735 次

请问该程序怎么出错了,怎么改?调试时显示ORA-00911: invalid character,但是这个查询语句在数据库里是正确的
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
  {
  string sql = null;
  oradb.oradb.connectstring = System.Configuration.ConfigurationManager.AppSettings["dycost"];
  Structure.Chart.ChartE chart = new Structure.Chart.ChartE();
  Structure.Chart.ChartE chart1 = new Structure.Chart.ChartE();
  switch (this.DropDownList2.SelectedIndex)
  {
  case 0: //按team统计
  sql = "select code_teamtype,teamtype,max(weight0) weight0,max(weight1) weight1,max(weight2) weight2,max(trains0) trains0,max(trains1) trains1,max(trains2) trains2 from " +
"(select code_teamtype,teamtype,case when tjdate=to_char(sysdate,'yyyy')-2 then weight end weight0,case when tjdate=to_char(sysdate,'yyyy')-1 then weight end weight1,case when tjdate=to_char(sysdate,'yyyy') then weight end weight2,case when tjdate=to_char(sysdate,'yyyy')-2 then trains end trains0,case when tjdate=to_char(sysdate,'yyyy')-1 then trains end trains1,case when tjdate=to_char(sysdate,'yyyy') then trains end trains2 from " +
"(select t.code_teamtype,teamtype, substr(TO_CHAR(TEAMDATE,'yyyymmdd'),1,4) tjdate,sum(t.weight) weight,sum(t.traincount) trains from vw_pro_trainwork t where substr(TO_CHAR(TEAMDATE,'yyyymmdd'),1,4) in(to_char(sysdate,'yyyy')-2,to_char(sysdate,'yyyy')-1,to_char(sysdate,'yyyy')) group by t.code_teamtype,teamtype,TEAMDATE ) " +
")group by code_teamtype,teamtype order by code_teamtype ";
  chart.argumentstr = "TEAMTYPE";
  chart.valuestr = new List<string>(new string[] { "weight0", "weight1", "weight2" });
  chart.name = new List<string>(new string[] { DateTime.Now.Date.AddYears(-2).ToString("yyyy") + "年", DateTime.Now.Date.AddYears(-1).ToString("yyyy") + "年", DateTime.Now.Date.ToString("yyyy") + "年" });
  chart.dtSource = oradb.oradb.filldata(sql).ToTable().Copy();//这里显示用户代码未处理oleDbException ORA-00911: invalid character
  //生成吨数柱状图
  Binding.Chart.ChartBar(chart, wcc3, "吨数完成情况");

  chart1.argumentstr = "TEAMTYPE";
  chart1.valuestr = new List<string>(new string[] { "trains0", "trains1", "trains2" });
  chart1.name = new List<string>(new string[] { DateTime.Now.Date.AddYears(-2).ToString("yyyy") + "年", DateTime.Now.Date.AddYears(-1).ToString("yyyy") + "年", DateTime.Now.Date.ToString("yyyy") + "年" });
  chart1.dtSource = oradb.oradb.filldata(sql).ToTable().Copy();
  //生成车数柱状图
  Binding.Chart.ChartBar(chart1, wcc4, "车数完成情况");
  break;
   
  case 1://按cargo统计
  sql = "select code_cargoproj,cargoproj,max(weight0) weight0,max(weight1) weight1,max(weight2) weight2,max(trains0) trains0,max(trains1) trains1,max(trains2) trains2 from " +
"(select code_cargoproj,cargoproj,case when tjdate=to_char(sysdate,'yyyy')-2 then weight end weight0,case when tjdate=to_char(sysdate,'yyyy')-1 then weight end weight1,case when tjdate=to_char(sysdate,'yyyy') then weight end weight2,case when tjdate=to_char(sysdate,'yyyy')-2 then trains end trains0,case when tjdate=to_char(sysdate,'yyyy')-1 then trains end trains1,case when tjdate=to_char(sysdate,'yyyy') then trains end trains2 from " +
"(sele