[英]Write null fields to xml file from datatable
DataSet ds = new DataSet();
string strData = "SELECT * FROM table";
DataTable dt = Globals.RealsoftObjects.GetDataTable(strData);
dtReportTypes.TableName = "table";
ds.Tables.Add(dt);
ds.WriteXml(sd.FileName,XmlWriteMode.WriteSchema);
I had used this code for write xml file from dataset. 我曾使用此代码从数据集中写入xml文件。 if there is a null value in table it doesn't write on xml. 如果表中有一个空值,则它不会写在xml上。
is there any solution? 有什么解决办法吗?
for example 例如
table have 2 fields field1 field2 and field1 is null xml writes only field2 with its value. 表具有2个字段field1 field2和field1为空xml只用其值写入field2。 I need field 1 also. 我还需要字段1。
use the code to write xml 使用代码编写xml
ds.WriteXml(sd.FileName,XmlWriteMode.WriteSchema);
this will read entire schema 这将读取整个架构
and to convert xml to datatable 并将xml转换为datatable
ds.ReadXml(strFileName,XmlReadMode.ReadSchema);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.