从字符串转换日期或时间时转换失败

时间:2018-01-31 11:40:51

标签: sql visual-studio date insert

这是我将insert数据插入数据库的插入语句。这是我的问题:

INSERT INTO JobsDB (Job_Name, Job_Desc, Job_Categ, Job_Qualif, Job_PayType, Job_Payrate, Job_PloyerName, Job_StartDate, Job_EndDate, Job_Status) VALUES ('" + tbName.Text + "' , '" + tbDescription.Text + "' , '" + ddCategory.Text + "' , '" + ddQualifications.Text + "' , '" + ddPayType.Text + "' , '" + tbRate.Text + "' , 'Kaslana' , '" + calendarStart.SelectedDate + "' , '" + calendarEnd.SelectedDate + "' , 'Active')

错误发生在代码从日历控件中获取所选日期的位置,并尝试将其插入数据库。

1 个答案:

答案 0 :(得分:0)

使用Convert.ToDateTime(YourSelectedDate)

{{1}}