下面的代码工作正常;每月1日至12日;但是,一旦我单击第 13 天或更大的日期,我就会收到此错误
Conversion failed when converting date and/or time from character string.
这是我的代码
DateTime dt = Convert.ToDateTime(Calendar1.SelectedDate.ToString("yyyy-MM-dd"));
myConnection.Open();
string cmdStr1 = "SELECT COUNT(*) FROM Payment WHERE PaymentDate = '" + dt + "'";
SqlCommand PIDexist1 = new SqlCommand(cmdStr1, myConnection);
int temp1 = Convert.ToInt32(PIDexist1.ExecuteScalar().ToString());
myConnection.Close();
感谢您的帮助
这是日期如何保存在我的数据库中2012-01-13