I have created a C# program that pulls data from a Database and dumps it down to XML which is then uploaded to a 3rd party. I just ran into a snag that i am sure is an easy fix.
My query will return mutiple rows and in one section of my code i need to pull the data from all of the rows and have it repeat an element in the XML file.
I have tried the if (sdr.HasRows) but i get an error. If the Query has 10 rows then i need 10 elements in the XML file. Does this make sense.
My query will return mutiple rows and in one section of my code i need to pull the data from all of the rows and have it repeat an element in the XML file.
I have tried the if (sdr.HasRows) but i get an error. If the Query has 10 rows then i need 10 elements in the XML file. Does this make sense.
Code:
[writer.WriteStartElement("collection");
writer.WriteAttributeString("id", "sCondDataSet");
//if (sdr.HasRows)
//{
// while (sdr.Read())
//{
writer.WriteStartElement("record");
writer.WriteStartElement("field");
writer.WriteAttributeString("id", "IsRequired");
writer.WriteString("True");
writer.WriteEndElement();
writer.WriteStartElement("field");
writer.WriteAttributeString("id", "Category");
writer.WriteString(Convert.ToString(sdr["Cond_Cat"]));
writer.WriteEndElement();
writer.WriteStartElement("field");
writer.WriteAttributeString("id", "CondDesc");
writer.WriteString(Convert.ToString(sdr["Cond_Desc"]));
writer.WriteEndElement();
//writer.WriteStartElement("field");
//writer.WriteAttributeString("id", "Notes");
//writer.WriteString("This is a Note");
//writer.WriteEndElement();
writer.WriteStartElement("field");
writer.WriteAttributeString("id", "DoneDate");
writer.WriteString(Convert.ToString(sdr["Cond_Clear_Date"]));
writer.WriteEndElement();
writer.WriteEndElement(); //Record
//}
//}
writer.WriteEndElement(); //Collection