我使用 MySQL 连接器接收数据表单数据库并将值放入数据集-> dataGridView。然后,当我单击带有复选框的列时,我需要更改日期列中的值:
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView1.Columns[e.ColumnIndex].Name == "Продано")
{
DataGridViewCheckBoxCell checkbox = (DataGridViewCheckBoxCell)dataGridView1.CurrentCell;
bool isChecked = (bool)checkbox.EditedFormattedValue;
DateTime dt = DateTime.Today;
dataGridView1.Rows[e.RowIndex].Cells[4].Value = dt.ToString("yyyy-MM-dd");
}
}
我需要将 DateTime 转换为 MySqlDateTime,以便在某些列中插入值。现在我有错误,需要 MySqlData 类型。
Unable to convert System.DateTime value to MySQL date/time