我試着查詢獲取數據(代碼如下),但它顯示我此錯誤爲特定月份和年份
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;
}
字符串SQL =「選擇d.DoctorID從Doctor_Master d其中d.LastName +''+ d.FirstName ='「+ DrName +」'AND Patient_registration.RegDate ='「+ monthYY +」'AND Patient_registration.DoctorID =「+ refDrID;檢查此查詢此查詢是特別問題檢查d.LastName +''+ d.FirstName ='「+ DrName +」' – SK2185
沒有,這是工作正常,問題與此字符串monthYY = dateTimePickerMonth.Value.ToString(「M -yy「);'這部分'Patient_registration.RegDate ='」+ monthYY +「'' – Durga
格式(dateTimePickerMonth.Value,」MM-yy「) – SK2185