我試圖從calender中選擇日期從asp.net到Microsoft SQL數據庫。插入日期時間從asp.net中的日曆到microsoft sql問題
當我選擇像01/04/2012
時間的工作,而是試圖插入30/01/2012
我得到消息時:
一個char數據類型到datetime數據類型的轉換導致 的OUT-範圍內的日期時間值。
當我創建datetime
目的是通過使用C#closeDateCalender.SelectedDate
, 代碼是:
sb.AppendFormat("Values('{0}', '{1}' ,'{2}', '{3}','{4}','{5}','{6}','{7}')",
opportunity.UserId,
opportunity.AccountId,
opportunity.OpportunityName,
opportunity.CloseDate,
opportunity.Stage,
opportunity.Probability,
opportunity.Amount,
opportunity.Description);
String prefix = "INSERT INTO Opportunities " + "([User_Id],Account_Id,Opportunity_Name,Close_Date,Stage,Probabilty,Amount,[Description])";
command = prefix + sb.ToString();
任何知道如何解決它???