响应json结果日期格式不正确

时间:2018-08-31 10:59:12

标签: web-services

[WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public void PATIENT(string patientID)
        {
            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            SqlConnection con = new SqlConnection("Data Source=172.16.1.96;Initial Catalog=OUTPATIENT_MODULE;User ID=SoftUser;Password=TecSrmc6789123");
            con.Open();

            SqlCommand cmd = new SqlCommand("SELECT [TitleName],[PatientName],[PatientID],[DateOfBirth],[Sex],[FatherHusbandName],[Nationality],[StreetName]+'  '+[AreaName]+'  '+[City]+'  '+[Taluk]+'  '+[District] as [Address],[State],[Country],[ZipCode],[Mobile],[Email],[LicenseNo],[PassportNo],[AdhaarCardNo],[CitizenNo] FROM[OUTPATIENT_MODULE].[dbo].[REGISTRATIONVIEW] where Recstatus = 'L' and RegistrationCode in ('01600000', '01610000') and  PatientID!='' and  PatientID =@PatientID  ", con);
            cmd.Parameters.AddWithValue("@PatientID", SqlDbType.VarChar).Value = patientID;
            cmd.ExecuteNonQuery();
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            // Create an instance of DataSet.
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            da.Fill(dt);

            con.Close();
            List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();
            Dictionary<string, object> row = null;
            foreach (DataRow rs in dt.Rows)
            {
                row = new Dictionary<string, object>();
                foreach (DataColumn col in dt.Columns)
                {
                    row.Add(col.ColumnName, rs[col]);
                }
                rows.Add(row);
            }

            this.Context.Response.ContentType = "application/json; charset=utf-8";
            this.Context.Response.Write(serializer.Serialize(new { Cargo = rows }));
        }

0 个答案:

没有答案