当我想从 access 中检索日期时,我在cmd1.ExecuteReader收到异常错误“No Value given for a or more parameters” 。这是我的代码
void checking_fields()
{
OleDbCommand cmd = new OleDbCommand("select movie_id from event", oc);
OleDbDataReader ol = cmd.ExecuteReader();
OleDbCommand cmd1 = new OleDbCommand("select [open date],[close date] from event", oc);
OleDbDataReader ol1 = cmd1.ExecuteReader();
while (ol1.Read())
{
if (ol1.GetValue(0).ToString() == dateTimePicker1.Value.ToString("MM/dd/yyyy") ||
ol1.GetValue(1).ToString() == dateTimePicker2.Value.ToString("MM/dd/yyyy"))
goto abc;
}
ol.Read();
if (textBox1.Text.Equals(ol.GetString(0)))
label8.Text = "ID already exists";
else
{
insert_database();
clear();
this.Close();
}
abc: label8.Text = "Open date or Close date already assigned";
}
这些是打开日期和关闭日期的属性
必需:否,索引:是(无重复),ime_mode:no_control,text_align:center,show_date_picker:for_dates
因为我是 C# 新手,请帮助我