代码为什么不执行啊?
运行程序后 按下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);