日期:2014-05-17 浏览次数:20415 次
StringBuilder sb = new StringBuilder(); string sql = "select * from users"; DataTable dt = DbHelperSQL.Query(sql).Tables[0]; sb.Append("{data:["); for (int i = 0; i < dt.Rows.Count; i++) { sb.Append("{\"id\":\"" + dt.Rows[i]["id"].ToString() + "\",\"name\":\"" + dt.Rows[i]["name"].ToString() + "\",\"tel\":\"" + dt.Rows[i]["tel"].ToString() + "\",\"mail\":\"" + dt.Rows[i]["mail"].ToString() + "\",\"qq\":\"" + dt.Rows[i]["qq"].ToString() + "\",\"datetime\":\"" + dt.Rows[i]["addtime"].ToString() + "\"}"); if (i != dt.Rows.Count - 1) { sb.Append(","); } } sb.Append("]}"); Response.Write(sb.ToString());