将DateTime值保存到microsoft access数据库中

时间:2015-02-26 19:00:54

标签: c# ms-access

我正在尝试保存一些数据以访问数据库,但日期存储的格式不正确

dbCommand.CommandText = "insert into Clients(Name,Gender,PhoneNumber,ReciveServiceDate) 
values ('" + name_txtBox.Text + "','" + gender_comBox.Text + "'," 
+ long.Parse(phone_txtBox.Text) + "," 
+ (recive_dateTimePicker.Value).ToShortDateString() + ");";

this is how date looks like in DB

1 个答案:

答案 0 :(得分:0)

听取Jon的建议。

但是,如果你坚持,你可以这样做:

+ (recive_dateTimePicker.Value).ToString("#yyyy'/'MM'/'dd#") + ");";