我的项目中有一个数据库,其中包含名为 'ProcessData' 的表和名为 'Start_At' (Type: DateTime) 和 'End_At' (Type: DateTime) 的列。
当我尝试在此表中输入新记录时,它以以下格式输入数据:'YYYY/MM/DD HH:mm',而我实际上希望它采用该格式:'YYYY/MM/DD HH :mm:ss' (没有出现秒数)。
有谁知道为什么,我应该怎么做才能解决这个问题?
这是我使用的代码:
con = new SqlConnection("....");
String startAt = "20100413 11:05:28";
String endAt = "20100414 11:05:28";
...
con.Open();//open the connection, in order to get access to the database
SqlCommand command = new SqlCommand("insert into ProcessData (Start_At, End_At) values('" + startAt + "','" + endAt + "')", con);
command.ExecuteNonQuery();//execute the 'insert' query.
con.Close();
非常感谢