我尝试了查询(在下面的代码中给出)但它向我显示了这个错误
No value given for one or more required parameters.
但是在调试时我正在传递日期
string monthYY = dateTimePickerMonth.Value.ToString("M-yy");
那么检查它的正确格式是什么,我该怎么做?
查询代码
public int GetDrID_MonthWise(string DrName,string monthYY,int refDrID)
{
int data = 0;
try
{
string sql = "Select d.DoctorID From Doctor_Master d where d.LastName + ' ' + d.FirstName = '" + DrName + "' AND Patient_registration.RegDate='" + monthYY + "' AND Patient_registration.DoctorID=" + refDrID;
cmd = new OleDbCommand(sql, acccon);
rs = cmd.ExecuteReader();
while (rs.Read())
{
data = Convert.ToInt32(rs[0]);
}
}
catch (Exception err)
{
MessageBox.Show(err.Message.ToString());
}
return data;
}