110,571
社区成员
发帖
与我相关
我的任务
分享
select *from table1 where lgidate>="2020-08-20" and lgitime>="17:16:41" and lgidate<="2020-08-21" and lgitime<="09:50:32";;
protected void Button2_Click(object sender, EventArgs e)
{
string startTime = TextBox1.Text.ToString().Trim();
string endTime = TextBox2.Text.ToString().Trim();
//创建字符串连接
string constr = "Server=localhost;UserId=root;Password=31;Database=userreco;pooling=false;CharSet=utf8;port=3306";//声明一个字符串用来存放连接数据库的信息
MySqlConnection sqlconn = new MySqlConnection(constr);//创建一个SqlConnection对象
//MySqlDataAdapter sqlda = new MySqlDataAdapter("select * from table1 where CONCAT(lgidate,' ',lgitime)>='" + startTime + "' ", sqlconn);
MySqlDataAdapter sqlda = new MySqlDataAdapter("select * from table1 where CONCAT(lgidate,' ',lgitime)>='" + startTime + "' and CONCAT(lgidate,' ',lgitime)<='" + endTime + "' ", sqlconn);
DataSet ds = new DataSet();
sqlda.Fill(ds);
this.GridView1.DataSource = ds;
this.GridView1.DataBind();
}
SELECT * FROM table1 WHERE CONCAT(lgidate,' ',lgitime)>='yyyy-MM-dd HH:mm:ss'
select *from table1 where CONCAT(lgidate,' ',lgitime)>='2020-08-20 17:12:16' and CONCAT(lgidate,' ',lgitime)<='2020-08-21 11:58:25';