mysql查询日期等于当前日期的sql

select  file_destination from ifi_filedb.file_order where file_name='${filename}' and 

date_format(create_time,'%Y-%m-%d')=date_format(now(),'%Y-%m-%d')order by

create_time desc limit1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
实现上述功能,需要编写 C# 代码来操作 DataGridView 和数据库。 首先,在窗体上添加一个 DataGridView 控件,并设置其 DataSource 属性为数据源。 然后,在窗体加载事件中,通过 SQL 查询语句从数据库中获取数据,并将其绑定到 DataGridView 控件上: ```csharp private void Form1_Load(object sender, EventArgs e) { string connectionString = "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=TestDB;Integrated Security=True"; string query = "SELECT * FROM MyTable"; SqlConnection connection = new SqlConnection(connectionString); SqlDataAdapter adapter = new SqlDataAdapter(query, connection); DataTable dataTable = new DataTable(); adapter.Fill(dataTable); dataGridView1.DataSource = dataTable; } ``` 接下来,为 DataGridView 控件的 CellContentClick 事件添加处理程序,以实现复选框选中行的第三列等于前两列之和的功能: ```csharp private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0) // 判断是否点击了复选框列 { int row = e.RowIndex; int sum = Convert.ToInt32(dataGridView1.Rows[row].Cells[1].Value) + Convert.ToInt32(dataGridView1.Rows[row].Cells[2].Value); dataGridView1.Rows[row].Cells[3].Value = sum; } } ``` 最后,为 DataGridView 控件的 CellDoubleClick 事件添加处理程序,以实现点击行使第八列的值等于前两列的和,并且第十列的时间等于今天的年月日,并且使用 update 语句将数据更新到数据库的功能: ```csharp private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { int row = e.RowIndex; int sum = Convert.ToInt32(dataGridView1.Rows[row].Cells[1].Value) + Convert.ToInt32(dataGridView1.Rows[row].Cells[2].Value); dataGridView1.Rows[row].Cells[7].Value = sum; dataGridView1.Rows[row].Cells[9].Value = DateTime.Today.ToString("yyyy-MM-dd"); int id = Convert.ToInt32(dataGridView1.Rows[row].Cells[0].Value); string connectionString = "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=TestDB;Integrated Security=True"; string query = "UPDATE MyTable SET Column2=@Column2, Column8=@Column8, Column10=@Column10 WHERE Id=@Id"; SqlConnection connection = new SqlConnection(connectionString); SqlCommand command = new SqlCommand(query, connection); command.Parameters.AddWithValue("@Column2", dataGridView1.Rows[row].Cells[1].Value); command.Parameters.AddWithValue("@Column8", dataGridView1.Rows[row].Cells[7].Value); command.Parameters.AddWithValue("@Column10", dataGridView1.Rows[row].Cells[9].Value); command.Parameters.AddWithValue("@Id", id); connection.Open(); command.ExecuteNonQuery(); connection.Close(); } ``` 以上代码中,需要将 connectionString 替换为自己的数据库连接字符串,以及将 MyTable、Column2、Column8、Column10 和 Id 替换为自己的表名和列名。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值