首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

代码为何不执行啊

2012-09-09 
代码为什么不执行啊?运行程序后 按下BUTTON 有要查询的内容,但是不完全一直。加断点调试,不走断点.为什么啊

代码为什么不执行啊?
 
运行程序后 按下BUTTON 有要查询的内容,但是不完全一直。加断点调试,不走断点.为什么啊?

  private void buttonX7_Click_1(object sender, EventArgs e)

  {
  if (checkBoxX1.Checked == true && checkBoxX2.Checked ==true )
  {
  if (radioButton1.Checked == true)
  {
  string id = this.comboBoxEx1.Text;
  string star = this.dateTimePicker1.Text;

  string finish = this.dateTimePicker2.Text;
  string P_Str_ConnectionStr = @"server=LIUSHIQI\YUYU;user id=sa;pwd=1;database=bbsDB";
  SqlConnection con = new SqlConnection(P_Str_ConnectionStr);
  string P_Str_SqlStr = "select stationid as 观测站编号,date as 观测时间,pm25 as 'PM2.5' ,PM10 as PM10 from rec_pm where stationid='" + id + "'and date>='" + star + "' and SUBSTRING(CONVERT(VARCHAR,date,120),0,14)<='" + finish + "'order by stationid;";

  SqlDataAdapter P_SqlDataAdapter = new SqlDataAdapter(P_Str_SqlStr, con);

  DataSet ds = new DataSet();


  P_SqlDataAdapter.Fill(ds);
  this.dataGridViewX1.DataSource = ds.Tables[0].DefaultView;
   
  }
  if (radioButton2.Checked == true)
  {
  string id = this.comboBoxEx1.Text;
  string star = this.dateTimePicker4.Text;

   
  string P_Str_ConnectionStr = @"server=LIUSHIQI\YUYU;user id=sa;pwd=1;database=bbsDB";
  SqlConnection con = new SqlConnection(P_Str_ConnectionStr);
  string P_Str_SqlStr = "select stationid as 观测站编号,date as 观测时间,pm25 as 'PM2.5' ,PM10 as PM10 from rec_pm where stationid='" + id + "'and datediff(day,[date],'"+ star +"')=0 order by stationid;";

  SqlDataAdapter P_SqlDataAdapter = new SqlDataAdapter(P_Str_SqlStr, con);

  DataSet ds = new DataSet();


  P_SqlDataAdapter.Fill(ds);
  this.dataGridViewX1.DataSource = ds.Tables[0].DefaultView;
   
  }
  if (radioButton3.Checked == true)
  {
  string id = this.comboBoxEx1.Text;
  string _year = this.comboBox4.Text;
  string _month = this.comboBox3.Text;


  string P_Str_ConnectionStr = @"server=LIUSHIQI\YUYU;user id=sa;pwd=1;database=bbsDB";
  SqlConnection con = new SqlConnection(P_Str_ConnectionStr);
  string P_Str_SqlStr = " delete from day_pm;insert into day_pm select stationid,datename(year,date),datename(mm,date),datename(dd,date),pm25,pm10 from rec_pm where datename(year,date)='" + _year + "' and datename(mm,date)='" + _month + "' and stationid='" + id + "';select stationid as 监测站编号,_year as 年份,_month as 月份,_day as 日期,convert(decimal(10,2),sum(pm25)) as 'PM2.5',avg(pm10) as PM10 from day_pm where _year='" + _year + "' and _month='" + _month + "' and stationid='"+ id +"' group by stationid,_year,_month,_day order by _day";
  SqlDataAdapter P_SqlDataAdapter = new SqlDataAdapter(P_Str_SqlStr, con);
  DataSet ds = new DataSet();


  P_SqlDataAdapter.Fill(ds);


  this.dataGridViewX1.Refresh();
  this.dataGridViewX1.DataSource = ds.Tables[0].DefaultView;
   
   
  }
  }
  }

[解决办法]
buttonX7_Click_1 看到这种形式,我觉得,你之前删除过,然后又加上去了

那么将整个button重新删除,包括后台方法

然后重新再添加一遍
[解决办法]
Designer文件 少了事件委托
this.buttonX7.Click += new System.EventHandler(this.buttonX7_Click_1);
[解决办法]

探讨

Designer文件 少了事件委托
this.buttonX7.Click += new System.EventHandler(this.buttonX7_Click_1);

[解决办法]
探讨
buttonX7_Click_1 看到这种形式,我觉得,你之前删除过,然后又加上去了

那么将整个button重新删除,包括后台方法

然后重新再添加一遍

热点排行