我正在使用数据集并将查询结果存储到该数据集中。 我的查询ID就像那样
String Query = @"SELECT * FROM TABLE1;
SELECT * FROM TABLE2;
SELECT * FROM TABLE3;";
我正在使用以下内容
XmlDocument relationSheepDoc = new XmlDocument();
StringWriter sWriter = new StringWriter();
XmlTextWriter xmlWriter = new XmlTextWriter(sWriter);
DataSet oDataSet = new DataSet("RelationSheeps");
oDataSet = sql.ExecuteSqlDataSet(Query);
string fileContent = string.Empty;
for (int i = 0; i < oDataSet.Tables.Count; i++)
{
oDataSet.Tables[i].WriteXml(xmlWriter, XmlWriteMode.WriteSchema);
fileContent = sWriter.ToString();
}
relationSheepDoc.LoadXml(fileContent);
xmlWriter.Close();
return relationSheepDoc;
它只写第一个表并生成异常 如何在同一个XML文件中编写所有三个表? 帮帮我...
答案 0 :(得分:0)
您应该立即编写整个DataSet,如下所示:
oDataSet.WriteXml(xmlWriter, XmlWriteMode.WriteSchema);