【发布时间】:2016-08-16 00:45:10
【问题描述】:
我们正在做一个应用程序,它使用 jsonservice(webservice/RESTfull webservice) 作为后端数据处理过程和 Andriod 作为前端..
public DataTable retrv(string id)
{
check();
int ID = Convert.ToInt32(id.ToString());
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "select * from RECVSSMS where Refid='" + ID + "'";
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
在使用 Android Studio 中的 jsonservice 使用此代码时,我们得到了除 Date_Time 之外的所有记录格式。
我们有这样的记录:
I/System.out:@@@@@@@@@@@@@@@@@@@@@@{"Value":[{"Date_time":"2016-04-22T02:01 :15","status":"1","Message":"测试消息回复自动","FromID":"+919566003138","Refid":24}],"Successful":true}
这里的错误很明显:Date_time":"2016-04-22T02:01:15"
出现字母“T”且日期格式不正确
这是数据库字段:
Refid int
FromID varchar(13)
Message varchar(60)
status varchar(5)
Date_Time datetime
【问题讨论】: