<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>General</title><link>https://www.infopathdev.com:443/forums/41.aspx</link><description>If you're not sure where to ask your question, ask it here. If necessary, our moderators will make sure it gets classified in the correct board.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Repeating table with 2 data sources.</title><link>https://www.infopathdev.com:443/forums/thread/82063.aspx</link><pubDate>Tue, 28 Aug 2012 16:40:08 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:82063</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/82063.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=82063</wfw:commentRss><description>&lt;p&gt;Run in debug to find out what&amp;#39;s null - here&amp;#39;s a &lt;a href="http://www.infopathdev.com/blogs/hilary/archive/2009/09/27/debug-managed-code-in-vsta-for-the-accidental-programmer.aspx"&gt;blog post&lt;/a&gt; with info on how to run your code in debug.&lt;/p&gt;</description></item><item><title>Repeating table with 2 data sources.</title><link>https://www.infopathdev.com:443/forums/thread/82055.aspx</link><pubDate>Tue, 28 Aug 2012 15:01:05 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:82055</guid><dc:creator>SP Tom</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/82055.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=82055</wfw:commentRss><description>Any help would be appreciated

So here is the error:


System.NullReferenceException
Object reference not set to an instance of an object.
   at repeating_table_to_list.FormCode.CTRL70_5_Clicked(Object sender, ClickedEventArgs e)
   at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
   at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)


The code:


//Connect to secondary data source 
DataSource ds = DataSources[&amp;quot;RE_Tasks&amp;quot;]; 
XPathNavigator domNav = ds.CreateNavigator(); XPathNodeIterator rows = domNav.Select(&amp;quot;/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW&amp;quot;, NamespaceManager); 

//Loop through secondary data source and populate the repeating table 

while (rows.MoveNext()) 
{ 

string Title =
rows.Current.SelectSingleNode(&amp;quot;Title&amp;quot;, NamespaceManager).Value.ToString(); 
string ID =
rows.Current.SelectSingleNode(&amp;quot;ID&amp;quot;,NamespaceManager).Value.ToString(); 
string Closing =
rows.Current.SelectSingleNode(&amp;quot;Closing&amp;quot;, NamespaceManager).Value.ToString();
using (XmlWriter writer =
MainDataSource.CreateNavigator().SelectSingleNode(&amp;quot;/my:MainDataSource/my:group4&amp;quot;,
NamespaceManager).AppendChild()) 

{ 
writer.WriteStartElement(&amp;quot;group5&amp;quot;, myNamespace); 
writer.WriteElementString(&amp;quot;Closing&amp;quot;,myNamespace ,Closing); 
writer.WriteElementString(&amp;quot;Title&amp;quot;,
myNamespace, Title); 
writer.WriteElementString(&amp;quot;ID&amp;quot;, myNamespace,
ID); 
writer.WriteEndElement(); 
writer.Close(); }</description></item></channel></rss>