I have an infopath form:
myFields (Group)
field2 (Field (element)) //this is a ListBox
The ListBox is auto populated from a DataSource and the "Entries" in the properties window is: "/dfs:myFields/dfs:dataFields/d:row"
I am querying the SQL database:
try
{
myConnection.Open();
SqlDataReader sdr = null;
string strQuery = @""; //query the sql table to get some data...
SqlDataAdapter sda = new SqlDataAdapter(strQuery, myConnection);
DataSet ds = new DataSet();
sda.Fill(ds);
XPathNavigator node = navigator.SelectSingleNode("/my:myFields/my:field2", this.NamespaceManager);
string strNS = node.NamespaceURI;
foreach (DataRow row in ds.Tables[0].Rows)
{
using (XmlWriter xw = node.AppendChild())
{
xw.WriteStartElement("myFields", strNS);
xw.WriteElementString("field2", strNS, row["CourseTime"].ToString()); //"CourseTime" is the column in the query
xw.WriteEndElement();
xw.Flush();
xw.Close(); //ERROR: Schema validation found non-data type errors.
}
}
}
How do I resolve the ERROR above? I am looking to clear out the entries for the ListBox and re-populate with the DataSet.