ayuan01230 于 2015.06.08 12:11 提问

string sql1 = "insert into shuju(sid,m1,date,time1,time2,m2,state,m3,status,m4,tq_state,m5,msg_count,m6,msg_bytes) values ('" + Convert.ToSingle(sid.Trim()) + "','" + Convert.ToSingle(m1.Trim()) + "','" + Convert.ToDateTime(date.Trim()) + "','" + Convert.ToDateTime(time1.Trim()) + "','" + Convert.ToSingle(time2.Trim()) + "','" + Convert.ToSingle(time2.Trim()) + "','" + Convert.ToSingle(m2.Trim()) + "','" + Convert.ToSingle(state.Trim()) + "','" +
Convert.ToSingle(m3.Trim()) + "','" + Convert.ToSingle(status.Trim()) + "','" + Convert.ToSingle(m4.Trim()) + "','" + Convert.ToSingle(tq_state.Trim()) + "','" + Convert.ToSingle(m5.Trim()) + "','" + Convert.ToSingle(msg_count.Trim()) + "','" + Convert.ToSingle(m6.Trim()) + "','" + Convert.ToSingle(msg_bytes.Trim()) + "')";

3 | 2015-04-01 00:00:02+08 | t | U | Good | 1113435 | 6666404

4个回答

devmiao      2015.06.08 14:49

Convert.ToDateTime
->
DateTime.ParseExact(你自己的时间格式)

baidu_25310663   2015.06.08 13:22
baidu_25310663 回复ayuan01230: 存入取出的时候注意转化一下就行了，其实没有那么复杂

ayuan01230 时间那列只能定位datetime么，其他的类型不行吗。我之前试过varchar

tongyi55555   2015.06.08 13:48

ayuan01230 C#存放到sql server中。

lezzyy   2015.06.08 15:07