dataSet.GetXml() doesn't return xml for null or blank columns

后端 未结 4 957
名媛妹妹
名媛妹妹 2021-01-06 00:51

When I call dataSet.GetXml() I don\'t get any xml returned for columns with null or blank values. Is there a simple, efficient way to get around this? An example of the prob

4条回答
  •  盖世英雄少女心
    2021-01-06 01:31

                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count == 0)
                {
                    foreach (DataTable dt in ds.Tables)
                    {
                        foreach (DataColumn dc in dt.Columns)
                        {
                            dc.DataType = typeof(String);
                        }
                    }
    
                    DataRow dr = ds.Tables[0].NewRow();
                    for (int i = 0; i < dr.ItemArray.Count(); i++)
                    {
                        dr[i] = string.Empty;
                    }
                    ds.Tables[0].Rows.Add(dr);
                }
    

提交回复
热议问题