SqlConnection aConnetion;
aConnetion = new SqlConnection("server=(local);database=lu;Trusted_Connection=yes");
string n = "select 事件1 from 事件 where 时间= '" + this.dateTimePicker1.Text + "'";
SqlDataReader reader; SqlCommand aCommand = new SqlCommand(n, aConnetion); aConnetion.Open();
reader = aCommand.ExecuteReader();
reader.Read();
label7.Text = reader.GetString(0);
aConnetion.Close();
上面代码中string n = "select 事件1 from 事件 where 时间= '" + this.dateTimePicker1.Text + "'";有错误,上次不知道怎么改了下好了,现在又有错误了,而且是
where 时间= '" + this.dateTimePicker1.Text + "'的错误,大家给我看看
aConnetion = new SqlConnection("server=(local);database=lu;Trusted_Connection=yes");
string n = "select 事件1 from 事件 where 时间= '" + this.dateTimePicker1.Text + "'";
SqlDataReader reader; SqlCommand aCommand = new SqlCommand(n, aConnetion); aConnetion.Open();
reader = aCommand.ExecuteReader();
reader.Read();
label7.Text = reader.GetString(0);
aConnetion.Close();
上面代码中string n = "select 事件1 from 事件 where 时间= '" + this.dateTimePicker1.Text + "'";有错误,上次不知道怎么改了下好了,现在又有错误了,而且是
where 时间= '" + this.dateTimePicker1.Text + "'的错误,大家给我看看
where 时间= '" + this.dateTimePicker1.Value.ToString() + "'";
试试
"select 事件1 from 事件 where 时间= '" + this.dateTimePicker1.Value.ToString("yyyy-MM-dd hh:mm:ss")+ "'";