请在我的访问数据库中有一个包含四列(名称,DOB,年龄,状态)的表。在我的程序中,如果条件为真,我希望状态行值自动更改。如果一个人的年龄在0-10状态栏=" Baby",10-20状态栏="青少年",20-50状态栏="成人&# 34;和50-100状态列="老年"。要自动拥有年龄我使用DateTime.today.year - DOB.year。View image
enter code here private void button1_Click(object sender, EventArgs e)
{
con.Open();
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = con;
string query = " select * from StatBD ";
cmd.CommandText = query;
DataTable dt = new DataTable();
OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
adapter.Fill(dt);
dataGridView1.DataSource = dt;
dataGridView1.Columns["N°"].Visible = true;
con.Close();
}