<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/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>Pashman's InfoPath Goldmine : Code Samples</title><link>http://blogs.msdn.com/timpash/archive/tags/Code+Samples/default.aspx</link><description>Tags: Code Samples</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Copying Data from a Secondary Datasource to a Child Table in a Main Datasource</title><link>http://blogs.msdn.com/timpash/archive/2007/02/23/copying-data-from-a-secondary-datasource-to-a-child-table-in-a-main-datasource.aspx</link><pubDate>Fri, 23 Feb 2007 18:41:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1747924</guid><dc:creator>timpash</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/timpash/comments/1747924.aspx</comments><wfw:commentRss>http://blogs.msdn.com/timpash/commentrss.aspx?PostID=1747924</wfw:commentRss><description>&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;This code sample documents a block of VB.Net code I had to write recently for retrieving a block of data from a secondary datasource, and then copying that data into a child table of a&amp;nbsp;dataset in the main datasource.&amp;nbsp;&amp;nbsp;&amp;nbsp; I've copied it over as is for my benefit as much as yours - I lost this code recently in a machine rebuild so want to have a copy somewhere!&amp;nbsp;&amp;nbsp; I believe the syntax shown here will be helpful to many of you.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;Public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/FONT&gt;&lt;FONT size=2&gt; GetEscalations_Clicked(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;FONT size=2&gt; sender &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Object&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;FONT size=2&gt; e &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; ClickedEventArgs)&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;' Write your code here.&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;' Define constants&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Const&lt;/FONT&gt;&lt;FONT size=2&gt; secondaryDataSourceName &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"GetUserEscalations"&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Const&lt;/FONT&gt;&lt;FONT size=2&gt; secondaryListXPath &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"/dfs:myFields/dfs:dataFields/ns3:GetUserEscalationsResponse/ns3:GetUserEscalationsResult/NewDataSet/Table"&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Const&lt;/FONT&gt;&lt;FONT size=2&gt; secondaryRelativeEscalationIDXPath &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"EscalationID"&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Const&lt;/FONT&gt;&lt;FONT size=2&gt; secondaryRelativeDataXPath &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"CompanyName"&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Const&lt;/FONT&gt;&lt;FONT size=2&gt; mainObservationEvidenceName &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"KeyObservationEvidence"&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Define strings for mapping values to main datasource evidence table.&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Const&lt;/FONT&gt;&lt;FONT size=2&gt; mainEvidenceKOID &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"KOID"&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Const&lt;/FONT&gt;&lt;FONT size=2&gt; mainEvidenceKOEvidenceID &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"KOEvidenceID"&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Const&lt;/FONT&gt;&lt;FONT size=2&gt; mainEvidenceKEID &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"KEID"&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Const&lt;/FONT&gt;&lt;FONT size=2&gt; mainEvidenceKEDetail &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"KEDetail"&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Const&lt;/FONT&gt;&lt;FONT size=2&gt; mainEvidenceKECreatedBy &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"KECreatedBy"&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Const&lt;/FONT&gt;&lt;FONT size=2&gt; mainEvidenceKECreatedDate &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"KECreatedDate"&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Const&lt;/FONT&gt;&lt;FONT size=2&gt; mainEvidenceKELastUpdatedBy &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"KELastUpdatedBy"&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Const&lt;/FONT&gt;&lt;FONT size=2&gt; mainEvidenceKELastUpdatedDate &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"KELastUpdatedDate"&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Const&lt;/FONT&gt;&lt;FONT size=2&gt; mainEvidenceKETypeID &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"KETypeID"&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Const&lt;/FONT&gt;&lt;FONT size=2&gt; mainEvidenceKETypeName &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"KETypeName"&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Const&lt;/FONT&gt;&lt;FONT size=2&gt; mainEvidenceKEDeleted &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"KEDeleted"&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Get navigator to the root of the main datasource. There will only ever be one record in the&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'main datasource.&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; mainDOMNavigator &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; XPathNavigator = MainDataSource.CreateNavigator()&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Explicitly create a pointer to the root element of the KO. This is the pointer that will drive the appending of the child Key Evidences.&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; mainDOMObservationNavigator &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; XPathNavigator&lt;/P&gt;
&lt;P&gt;mainDOMObservationNavigator = mainDOMNavigator.SelectSingleNode(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"/dfs:myFields/dfs:dataFields/tns:GetKOsDataSetByQuickSearchResponse/tns:GetKOsDataSetByQuickSearchResult/NewDataSet/KeyObservation"&lt;/FONT&gt;&lt;FONT size=2&gt;, NamespaceManager)&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Get navigator to the root of the secondary datasource.&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; secondaryDataSource &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; DataSource = DataSources.Item(secondaryDataSourceName)&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; secondaryDOMNavigator &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; XPathNavigator = secondaryDataSource.CreateNavigator()&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Setting up some other XPathNavigator Pointers&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; secondaryEscalationIDNavigator &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; XPathNavigator&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; secondaryEscalationEvidenceNavigator &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; XPathNavigator&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; secondaryListItem &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; XPathNavigator&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; escalationIDMapping &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; escalationEvidence &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Get all the list items from the secondary datasource.&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; secondaryListItems &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; XPathNodeIterator = secondaryDOMNavigator.Select(secondaryListXPath, NamespaceManager)&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Do&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;While&lt;/FONT&gt;&lt;FONT size=2&gt; secondaryListItems.MoveNext()&lt;/P&gt;
&lt;P&gt;secondaryListItem = secondaryListItems.Current&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Get observation Id for the list item.&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;secondaryEscalationIDNavigator = secondaryListItem.SelectSingleNode(secondaryRelativeEscalationIDXPath, NamespaceManager)&lt;/P&gt;
&lt;P&gt;escalationIDMapping = secondaryEscalationIDNavigator.Value&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Get the evidence to be copied into the main DOM.&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;secondaryEscalationEvidenceNavigator = secondaryListItem.SelectSingleNode(secondaryRelativeDataXPath, NamespaceManager)&lt;/P&gt;
&lt;P&gt;escalationEvidence = secondaryEscalationEvidenceNavigator.Value&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Nothing&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;IsNot&lt;/FONT&gt;&lt;FONT size=2&gt; mainDOMObservationNavigator &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Then&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Append the evidence child&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Using&lt;/FONT&gt;&lt;FONT size=2&gt; evidenceChild &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; XmlWriter = mainDOMObservationNavigator.AppendChild()&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; prefix &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; = mainDOMObservationNavigator.Prefix&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; namespaceUri &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; = mainDOMObservationNavigator.NamespaceURI&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteStartElement(prefix, mainObservationEvidenceName, namespaceUri)&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteStartElement(prefix, mainEvidenceKOID, namespaceUri)&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteValue(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"-1"&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteEndElement()&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteStartElement(prefix, mainEvidenceKOEvidenceID, namespaceUri)&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteValue(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"-1"&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteEndElement()&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteStartElement(prefix, mainEvidenceKEID, namespaceUri)&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteValue(escalationIDMapping)&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteEndElement()&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteStartElement(prefix, mainEvidenceKEDetail, namespaceUri)&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteValue(escalationEvidence)&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteEndElement()&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteStartElement(prefix, mainEvidenceKECreatedBy, namespaceUri)&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteValue(currentUser())&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteEndElement()&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteStartElement(prefix, mainEvidenceKECreatedDate, namespaceUri)&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteValue(currentDateTime())&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteEndElement()&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteStartElement(prefix, mainEvidenceKELastUpdatedBy, namespaceUri)&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteValue(currentUser())&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteEndElement()&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteStartElement(prefix, mainEvidenceKELastUpdatedDate, namespaceUri)&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteValue(currentDateTime())&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteEndElement()&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteStartElement(prefix, mainEvidenceKETypeID, namespaceUri)&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteValue(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"1"&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteEndElement()&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteStartElement(prefix, mainEvidenceKETypeName, namespaceUri)&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteValue(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"Escalation SR#"&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteEndElement()&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteStartElement(prefix, mainEvidenceKEDeleted, namespaceUri)&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteValue(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;False&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteEndElement()&lt;/P&gt;
&lt;P&gt;evidenceChild.WriteEndElement()&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Using&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Loop&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Private&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Function&lt;/FONT&gt;&lt;FONT size=2&gt; currentDateTime() &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; mainDomNavigator &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; XPathNavigator = MainDataSource.CreateNavigator()&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; todayNavigator &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; XPathNavigator = mainDomNavigator.SelectSingleNode(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"/dfs:myFields/my:TodaysDate"&lt;/FONT&gt;&lt;FONT size=2&gt;, NamespaceManager)&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Return&lt;/FONT&gt;&lt;FONT size=2&gt; todayNavigator.Value&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Function&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Private&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Function&lt;/FONT&gt;&lt;FONT size=2&gt; currentUser() &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; mainDomNavigator &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; XPathNavigator = MainDataSource.CreateNavigator()&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; userNavigator &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; XPathNavigator = mainDomNavigator.SelectSingleNode(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"/dfs:myFields/my:CurrentUser"&lt;/FONT&gt;&lt;FONT size=2&gt;, NamespaceManager)&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Return&lt;/FONT&gt;&lt;FONT size=2&gt; userNavigator.Value&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Function&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1747924" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/timpash/archive/tags/Code+Samples/default.aspx">Code Samples</category></item><item><title>XPathNavigator Control in VB.NET</title><link>http://blogs.msdn.com/timpash/archive/2007/02/15/xpathnavigator-control-in-vb-net.aspx</link><pubDate>Fri, 16 Feb 2007 04:14:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1686381</guid><dc:creator>timpash</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/timpash/comments/1686381.aspx</comments><wfw:commentRss>http://blogs.msdn.com/timpash/commentrss.aspx?PostID=1686381</wfw:commentRss><description>&lt;P&gt;VB.NET and probably the other managed code languages uses a new syntax for specifying nodes and traversing XML in a form.&amp;nbsp;&amp;nbsp; I don't claim to have a firm grasp on this, I only know what works.&amp;nbsp;&amp;nbsp; Let's say you've got a&amp;nbsp;field&amp;nbsp;in your form whose value you set via rules or defaults, like a datetime field.&amp;nbsp;&amp;nbsp; Below is how you would specify a function to get into your main datasource, get to the value, set it to a variable and then do something with it.&amp;nbsp; This may be basic info for some of you, but it's a different syntax to me and is worth noting here.&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Private&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Function&lt;/FONT&gt;&lt;FONT size=2&gt; currentDateTime() &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; mainDomNavigator &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; XPathNavigator = MainDataSource.CreateNavigator()&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; todayNavigator &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; XPathNavigator = mainDomNavigator.SelectSingleNode(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"/dfs:myFields/my:TodaysDate"&lt;/FONT&gt;&lt;FONT size=2&gt;, NamespaceManager)&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Return&lt;/FONT&gt;&lt;FONT size=2&gt; todayNavigator.Value&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Function&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1686381" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/timpash/archive/tags/Code+Samples/default.aspx">Code Samples</category></item><item><title>Custom Task Panes in InfoPath 2007 Using VB.NET</title><link>http://blogs.msdn.com/timpash/archive/2007/02/15/custom-task-panes-in-infopath-2007-using-vb-net.aspx</link><pubDate>Fri, 16 Feb 2007 04:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1686363</guid><dc:creator>timpash</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/timpash/comments/1686363.aspx</comments><wfw:commentRss>http://blogs.msdn.com/timpash/commentrss.aspx?PostID=1686363</wfw:commentRss><description>&lt;P&gt;Folks,&lt;/P&gt;
&lt;P&gt;Just starting to get involved in dealing with VB.NET and VSTA in InfoPath 2007.&amp;nbsp;&amp;nbsp; A lot of what I've taken for granted in InfoPath 2003 and JScript no longer applies.&amp;nbsp;&amp;nbsp; Take Custom Task Panes for example.&amp;nbsp;&amp;nbsp; A neat idea, and super-useful.&amp;nbsp;&amp;nbsp; Doesn't work the same way&amp;nbsp;in InfoPath 2007.&amp;nbsp;&amp;nbsp; Well some of it does.&amp;nbsp;&amp;nbsp; For example, the format of the typical html file that you would use as a resource file for the task pane is formatted the same.&amp;nbsp;&amp;nbsp; For those of you that haven't built one before, you'll copy and paste this into "mission-critcal notepad" and edit from there.&amp;nbsp;&amp;nbsp;Here is a sample:&lt;/P&gt;
&lt;P&gt;&amp;lt;html&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;lt;body&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;lt;font face="arial" color="black"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;div id="fieldname1" style="display:none"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;p&amp;gt;&amp;lt;font color="blue"&amp;gt;&amp;lt;b&amp;gt;KO Title&amp;lt;/b&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/p&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;br /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Your text will appear here in the task pane.&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;br&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/div&amp;gt;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;div id="fieldname2" style="display:none"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;p&amp;gt;&amp;lt;font color="blue"&amp;gt;&amp;lt;b&amp;gt;KO Type&amp;lt;/b&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/p&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;br /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Your different text will appear here in the task pane.&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/div&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;lt;/font&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;lt;/body&amp;gt;&lt;BR&gt;&amp;lt;/html&amp;gt;&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;The idea is that you have a div statement that separates what content to show when.&amp;nbsp;&amp;nbsp; In InfoPath 2007, you'll go to the programming choices off the menu and choose Context Changed Event.&amp;nbsp; This will put an event handler in place and stub out the code you need.&amp;nbsp;&amp;nbsp;&amp;nbsp; Here is the code that works for me:&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;Private&lt;/FONT&gt;&lt;FONT size=2&gt; helpString &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&amp;nbsp;&lt;FONT size=2&gt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/FONT&gt;&lt;FONT size=2&gt; FormEvents_ContextChanged(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;FONT size=2&gt; sender &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Object&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;FONT size=2&gt; e &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; ContextChangedEventArgs)&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Try&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;/FONT&gt;&lt;FONT size=2&gt; (e.ChangeType = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"ContextNode"&lt;/FONT&gt;&lt;FONT size=2&gt;) &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Then&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;' The XML selection or context has changed.&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Retrieve task pane object&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; customTaskPane &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; HtmlTaskPane = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;FONT size=2&gt;.CurrentView.Window.TaskPanes.Item(0)&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Get the collection of html elements in the task pane.&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; htmlDocument &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; mshtml.HTMLDocument = customTaskPane.HtmlDocument&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; htmlDocumentAll &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; IHTMLElementCollection = htmlDocument.all&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Clear previous help topic from task pane&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Not&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt;.IsNullOrEmpty(helpString) &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Then&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Get the first div that matches the helpString.&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; htmlOldDivElem &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; mshtml.HTMLDivElement = htmlDocumentAll.item(helpString, 0)&lt;/P&gt;
&lt;P&gt;htmlOldDivElem.style.display = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"none"&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Keep record of string to be displayed, so it can later be cleared&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;helpString = e.Context.Name&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Get the first div that matches the helpString.&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; htmlDivElem &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; mshtml.HTMLDivElement = htmlDocumentAll.item(helpString, 0)&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Nothing&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Is&lt;/FONT&gt;&lt;FONT size=2&gt; htmlDivElem &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Then&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'No known context node.&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;helpString = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Nothing&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Else&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Display DIV statement having same ID as the context node name&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;htmlDivElem.style.display = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt;.Empty&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Return&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Catch&lt;/FONT&gt;&lt;FONT size=2&gt; exn &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; Exception&lt;/P&gt;
&lt;P&gt;MessageBox.Show(exn.ToString())&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Try&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;I assume that you know how to tell the form to use a Custom Task Pane and to upload the html file you built previously as a resource file and associate it with the Custom Task Pane.&amp;nbsp; The only thing that sucks about this is that the form requires full trust with a level 2 code signing cert.&amp;nbsp;&amp;nbsp; I've self-signed my form for now, but am hoping to get a resolution to that. At least InfoPath 2007 doesn't completely shut you down when it sees an untrusted cert like InfoPath 2003 did.&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1686363" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/timpash/archive/tags/Code+Samples/default.aspx">Code Samples</category></item><item><title>Getting Current User in InfoPath 2007 via C#</title><link>http://blogs.msdn.com/timpash/archive/2006/08/22/InfoPath-2007-CSharp-Code-For-Retrieval-of-Username.aspx</link><pubDate>Tue, 22 Aug 2006 17:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:712648</guid><dc:creator>timpash</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/timpash/comments/712648.aspx</comments><wfw:commentRss>http://blogs.msdn.com/timpash/commentrss.aspx?PostID=712648</wfw:commentRss><description>&lt;P&gt;Folks,&lt;/P&gt;
&lt;P&gt;Got a little code sample from a fellow watcher of Pashman's Goldmine (thanks Huseyin) on how to retreive the username of the current user via C# code.&amp;nbsp; Since all code samples are useful, I've posted it below:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue"&gt;public&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; FormEvents_Loading(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: teal"&gt;LoadingEventArgs&lt;/SPAN&gt; e) &lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue"&gt;string&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt; xpath = &lt;SPAN style="COLOR: maroon"&gt;"/my:oneriForm/my:nameTxt"&lt;/SPAN&gt;; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue"&gt;string&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt; userName1; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: teal"&gt;XPathNavigator&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt; field1 = MainDataSource.CreateNavigator().SelectSingleNode(xpath, NamespaceManager); &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: green"&gt;//string oldValue = field1.Value; // Read&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue"&gt;string&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt; strUserName = System.&lt;SPAN style="COLOR: teal"&gt;Environment&lt;/SPAN&gt;.UserName; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: green"&gt;//userName1 = System.Environment.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;field1.SetValue(strUserName); &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 12pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: green"&gt;// Write&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;In this case the user wanted the full user name too, and I advised him to try and replace the System.Environment.UserName with System.Environment.FriendlyName.&amp;nbsp;&amp;nbsp; I'll let you know if that worked.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=712648" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/timpash/archive/tags/Code+Samples/default.aspx">Code Samples</category></item><item><title>Programmatically Launching Another Form from Within a Form</title><link>http://blogs.msdn.com/timpash/archive/2006/07/27/680717.aspx</link><pubDate>Fri, 28 Jul 2006 00:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:680717</guid><dc:creator>timpash</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/timpash/comments/680717.aspx</comments><wfw:commentRss>http://blogs.msdn.com/timpash/commentrss.aspx?PostID=680717</wfw:commentRss><description>&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas&gt;Application.XDocuments.NewFromSolution(urlToXsnFile) or Application.XDocuments.Open(urlToXmlFile)&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas&gt;Your form will need to require full trust in order to use either of these OM methods.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas&gt;Keep it simple, right?&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas&gt;Tim&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=680717" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/timpash/archive/tags/Code+Samples/default.aspx">Code Samples</category></item><item><title>Manipulating Secondary Datasources using C#</title><link>http://blogs.msdn.com/timpash/archive/2006/06/12/CSharp-And-Secondary-Datasources.aspx</link><pubDate>Mon, 12 Jun 2006 15:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:628095</guid><dc:creator>timpash</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/timpash/comments/628095.aspx</comments><wfw:commentRss>http://blogs.msdn.com/timpash/commentrss.aspx?PostID=628095</wfw:commentRss><description>&lt;FONT size=2&gt;
&lt;P&gt;Hey folks,&lt;/P&gt;
&lt;P&gt;Like many of you, I'm being dragged into the land of managed code in order to achieve things that I've had oodles of JScript code samples to do for a long time.&amp;nbsp;&amp;nbsp; The InfoPath Toolkit for VS.NET allows you to write code in either VB or C#; since C# looked more like JScript, and I had both JScript and C# code samples for the easy part of what I wanted to do, I decided to go with C#.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the task at hand that I needed to do was to pick up the username attribute from the local environment and populate that into a field on the form, and then use that field as a lookup value into a secondary datasource and populate a "friendly" username and office location number and friendly name for the office location as well.&amp;nbsp;&amp;nbsp; Oh by the way I needed to do it all in the OnLoad event of the form.&amp;nbsp; This sounds easy - and in fact the username part was super-easy.&amp;nbsp;&amp;nbsp; Getting the right syntax though to address the secondary datasource and pluck values out was a major pain in the butt.&amp;nbsp;&amp;nbsp; To make matters worse, my form was tied to a database, so the namespaces are all "dfs" and "d" instead of "my".&amp;nbsp; It gets confusing since all datasources that are SQL-based follow the same basic nomenclature, and you have to figure out how to navigate between them.&amp;nbsp;&amp;nbsp; The only thing that might be hard to follow below is the fact that I don't store the friendly office location name in the destination table that the form is tied to, so in my schema I just created a node outside of the dataFields to hold the friendly office location name for purposes of display.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[InfoPathEventHandler(EventType=InfoPathEventType.OnLoad)]&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;FONT size=2&gt; OnLoad(DocReturnEvent e)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// This code populates the local username. This was the easy part.&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;IXMLDOMNode nodeEmployee=thisXDocument.DOM.selectSingleNode("dfs:myFields/dfs:dataFields/d:DestinationTable/@username");&lt;/P&gt;
&lt;P&gt;nodeEmployee.text=System.Environment.UserName;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;//Call the LookupTable datasource and populate other fields.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000 size=2&gt;//This variable declaration looked very foreign to me.&amp;nbsp; Chalk that up to being new to C#&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;DOMDocument50 objPeopleStuff = (DOMDocument50)thisXDocument.GetDOM("LookupTable");&lt;/P&gt;
&lt;P&gt;objPeopleStuff.setProperty("SelectionNamespaces","xmlns:dfs='http://schemas.microsoft.com/office/infopath/2003/dataFormSolution'"+" xmlns:d='http://schemas.microsoft.com/office/infopath/2003/ado/dataFields'");&lt;/P&gt;
&lt;P&gt;ADOAdapterObject myAdapter = (ADOAdapterObject)thisXDocument.DataAdapters["LookupTable"];&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;//This method below seemed to be clunky to me at first, but turns out to be helpful later, as you'll want &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;//to set the query string back to nominal later on.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; origCommand = "";&lt;/P&gt;
&lt;P&gt;origCommand=myAdapter.Command; &lt;/P&gt;
&lt;P&gt;myAdapter.Command=origCommand + " WHERE username = '"+ nodeEmployee.text +"'";&lt;/P&gt;
&lt;P&gt;myAdapter.Query();&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;//Sets friendly name value&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;IXMLDOMNode nodeFriendlyName=thisXDocument.DOM.selectSingleNode("dfs:myFields/dfs:dataFields/d:DestinationTable/@friendlyname");&lt;/P&gt;
&lt;P&gt;IXMLDOMNode nodeReturnedName=objPeopleStuff.selectSingleNode("dfs:myFields/dfs:dataFields/d:LookupTable/@FriendlyName");&lt;/P&gt;
&lt;P&gt;nodeFriendlyName.text=nodeReturnedName.text;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;//Sets office code unfriendly value&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;IXMLDOMNode nodeUnFriendlyOfficeName=thisXDocument.DOM.selectSingleNode("dfs:myFields/dfs:dataFields/d:DestinationTable/@officecode");&lt;/P&gt;
&lt;P&gt;IXMLDOMNode nodeReturnedCodedOffice=objPeopleStuff.selectSingleNode("dfs:myFields/dfs:dataFields/d:LookupTable/@OfficeCode");&lt;/P&gt;
&lt;P&gt;nodeUnFriendlyOfficeName.text=nodeReturnedCodedOffice.text;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;//Sets office code friendly value. Small nuance here is that I was lazy&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;//and don't write OfficeName to actual destination table. Follow syntax of other nodes in &lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;//actual solution.&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;IXMLDOMNode nodeFriendlyOfficeName=thisXDocument.DOM.selectSingleNode("dfs:myFields/my:OfficeName");&lt;/P&gt;
&lt;P&gt;IXMLDOMNode nodeReturnedOffice=objPeopleStuff.selectSingleNode("dfs:myFields/dfs:dataFields/d:LookupTable/@OfficeName");&lt;/P&gt;
&lt;P&gt;nodeFriendlyOfficeName.text=nodeReturnedOffice.text;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;//resets the lookup dataconnection to remove WHERE clause&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;myAdapter.Command=origCommand;&lt;/P&gt;
&lt;P&gt;myAdapter.Query();&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;Unfortunately, this code does need the form to have full trust and be signed with a Level 2 code signing certificate to run.&amp;nbsp;&amp;nbsp; That's a bummer, but I see no way around it for now.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Tim&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=628095" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/timpash/archive/tags/Code+Samples/default.aspx">Code Samples</category></item><item><title>Increasing the TimeOut Value on Database Submit</title><link>http://blogs.msdn.com/timpash/archive/2006/05/31/Increase-Submit-Timeout-Value.aspx</link><pubDate>Wed, 31 May 2006 15:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:611603</guid><dc:creator>timpash</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/timpash/comments/611603.aspx</comments><wfw:commentRss>http://blogs.msdn.com/timpash/commentrss.aspx?PostID=611603</wfw:commentRss><description>&lt;P&gt;Folks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Had an issue recently where a user of one of my solutions had pretty terrible bandwidth to the SQL server where they needed to submit data.&amp;nbsp;&amp;nbsp; The default timeout value on submits is 30 seconds.&amp;nbsp;&amp;nbsp; As it turn out, the default for queries too is 30 seconds.&amp;nbsp;&amp;nbsp; You can reset that value fairly easily in code.&amp;nbsp;&amp;nbsp;&amp;nbsp; Here is an example of code that you put behind the submit button to increase the timeout value, do the submit and throw up a thank you message:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;XDocument.QueryAdapter.Timeout=120; &lt;/P&gt;
&lt;P&gt;XDocument.Submit(); &lt;/P&gt;
&lt;P&gt;XDocument.UI.Alert("Thanks for using the AD Data Collection Form");&lt;/P&gt;
&lt;P&gt;I'm pretty sure that if you tweak the value for the timeout, it applies to every query and the submit behavior in your form.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Tim&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=611603" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/timpash/archive/tags/Code+Samples/default.aspx">Code Samples</category></item><item><title>Drop the Solution Version Number in a Field</title><link>http://blogs.msdn.com/timpash/archive/2006/03/28/Put-Solution-Version-In-Text-Field.aspx</link><pubDate>Tue, 28 Mar 2006 15:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:562962</guid><dc:creator>timpash</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/timpash/comments/562962.aspx</comments><wfw:commentRss>http://blogs.msdn.com/timpash/commentrss.aspx?PostID=562962</wfw:commentRss><description>Simple question, simple answer.&amp;nbsp;&amp;nbsp; Let's say you want to tell
a user what version of the solution they are using.&amp;nbsp;&amp;nbsp;
Technically the way the InfoPath works they don't need to worry about
that, but let's just say you wanted to tell them.&amp;nbsp;&amp;nbsp; The
following code shows you how to grab a node and push the solution
version value into a text field associated with the node.&amp;nbsp;&amp;nbsp;
Thanks once again to Scott Heim for this snippet.&lt;br&gt;
&lt;br&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 11pt; color: rgb(31, 73, 125); font-family: Calibri;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
var objField1 = 
XDocument.DOM.selectSingleNode("//my:myFields/my:field1");&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 11pt; color: rgb(31, 73, 125); font-family: Calibri;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
objField1.text = XDocument.Solution.Version;&lt;br&gt;
&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;Easy as pie.&lt;br&gt;
&lt;span style="font-size: 11pt; color: rgb(31, 73, 125); font-family: Calibri;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=562962" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/timpash/archive/tags/Code+Samples/default.aspx">Code Samples</category></item><item><title>Dynamic Efficient Querying of Large Datasets</title><link>http://blogs.msdn.com/timpash/archive/2006/03/02/Efficiently-Querying-Large-Datasets.aspx</link><pubDate>Thu, 02 Mar 2006 14:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:542002</guid><dc:creator>timpash</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/timpash/comments/542002.aspx</comments><wfw:commentRss>http://blogs.msdn.com/timpash/commentrss.aspx?PostID=542002</wfw:commentRss><description>&lt;P&gt;Folks,&lt;/P&gt;
&lt;P&gt;I have done a lot of work with making InfoPath live up to it's promise of providing an offline experience.&amp;nbsp; That promise becomes a lot harder to fulfill when you are querying large datasets in your form to populate one dropdown lists or more likely a series of cascading dropdowns.&amp;nbsp;&amp;nbsp; The issue is that you need the whole dataset returned in order to work with it and filter it.&amp;nbsp;&amp;nbsp; At least that's true in the traditional sense where you are lazy and don't want to refine it at all (describes me pretty well).&amp;nbsp;&amp;nbsp;&amp;nbsp; So I got pinned down by a customer the other day who said they they don't want to pull back a giant dataset, but rather want to pass parameters to a SQL Stored Procedure which then performs a much more intelligent query that only brings back the data they need.&amp;nbsp;&amp;nbsp; I thought that was a swell idea, but had no idea how to pluck values out of the form and pass them as query parameters to a stored procedure.&amp;nbsp;&amp;nbsp; So it turns out that someone wrote a whitepaper on just that, which I'm providing a link to right here &lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: #1f497d"&gt;&lt;A href="http://support.microsoft.com/default.aspx?scid=kb;EN-US;827007"&gt;&lt;FONT face=Calibri&gt;http://support.microsoft.com/default.aspx?scid=kb;EN-US;827007&lt;/FONT&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: #1f497d"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: #1f497d"&gt;&lt;FONT color=#000000 size=3&gt;Now, I don't claim to know anything about Stored Procedures, although it's on my list of things to learn in the short term.&amp;nbsp;&amp;nbsp; What I will tell you is that when I posted this problem to a set of internal gurus, I got some interesting responses where you could simply build a dynamic query in code that served the same end as a stored procedure.&amp;nbsp;&amp;nbsp; The code snippet below makes perfect sense to me and would probably be my preferred way to get this done.&amp;nbsp;&amp;nbsp; Check it out&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: #1f497d"&gt;&lt;FONT color=#000000 size=3&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: #1f497d"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial; mso-fareast-font-family: Arial"&gt;&lt;SPAN style="mso-list: Ignore"&gt;1)&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;Create a “query” button; use “rules and custom code” as its action, then click Edit Code&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial; mso-fareast-font-family: Arial"&gt;&lt;SPAN style="mso-list: Ignore"&gt;2)&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;Customize the following code snippet to set the SQL command dynamically:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;FONT color=#000000&gt;// get the value of the DOM node that we’ll use to append to the WHERE clause&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;FONT color=#000000&gt;currentElementID = XDocument.DOM.selectSingleNode("/mf:myFields/my:currentElementID").text;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;o:p&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;FONT color=#000000&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;// get the data adapter object&lt;/SPAN&gt;&lt;SPAN lang=RU style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: RU"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;FONT color=#000000&gt;myDataAdapter = XDocument.DataAdapters("Revisions"); &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;o:p&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;FONT color=#000000&gt;// set the SQL command property of the data adapter, providing a dynamic WHERE clause&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;FONT color=#000000&gt;myDataAdapter.Command = "select RevisionBy, RevisionText from Revision WHERE UIElementID = '" + currentElementID + "'";&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;o:p&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;FONT color=#000000&gt;// execute the query&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;FONT color=#000000&gt;myDataAdapter.Query();&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT color=#000000&gt;Special credit goes out to Scott Heim and Alex Vaynshteyn on this one.&lt;/FONT&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=542002" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/timpash/archive/tags/Code+Samples/default.aspx">Code Samples</category></item><item><title>Jumping Around in a Long Form</title><link>http://blogs.msdn.com/timpash/archive/2006/02/09/Navigating-Long-Forms.aspx</link><pubDate>Thu, 09 Feb 2006 19:26:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:528672</guid><dc:creator>timpash</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/timpash/comments/528672.aspx</comments><wfw:commentRss>http://blogs.msdn.com/timpash/commentrss.aspx?PostID=528672</wfw:commentRss><description>&lt;p&gt;Hi Everybody,&lt;/p&gt;
&lt;p&gt;Hey sometimes you get a long form that requires you to do a lot of scrolling around to get to to the different sections.&amp;nbsp;&amp;nbsp; I use a lot of tricks with views and/or conditionally hidden sections to make things look like they all fit on one page.&amp;nbsp; Nevertheless, there are some of you that just want a big 'ole form, but need some navigation.&amp;nbsp;&amp;nbsp; I asked the question of the true experts and they gave a very simple code sample that shows how to enable that.&lt;/p&gt;
&lt;p&gt;function yourcontrolname::OnClick(eventObj)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;var objfield2= XDocument.DOM.selectSingleNode("//my:myFields/my:field2");&lt;/p&gt;
&lt;p&gt;XDocument.View.SelectText(objField2);&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;It's fairly self explanatory.&amp;nbsp;&amp;nbsp; You assign a variable to a node value and then use the SelectText call to navigate to that node.&amp;nbsp;&amp;nbsp; The original sender of this idea, Scott Heim, also informed me that you modify a button to the point where it looks just like a hyperlink if you so desire.&amp;nbsp; I prefer a button myself but that's not for everyone.&amp;nbsp; Enjoy.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=528672" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/timpash/archive/tags/Code+Samples/default.aspx">Code Samples</category></item><item><title>Adding Data to Dropdowns and Requerying in One Step</title><link>http://blogs.msdn.com/timpash/archive/2006/02/07/Update-New-Value-In-DropdownList-and-Requery-In-One-Step.aspx</link><pubDate>Tue, 07 Feb 2006 19:48:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:526729</guid><dc:creator>timpash</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/timpash/comments/526729.aspx</comments><wfw:commentRss>http://blogs.msdn.com/timpash/commentrss.aspx?PostID=526729</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Arial size=2&gt;Folks,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;FONT size=2&gt;Ran into a sticky issue the other day where a customer wanted a drop down list to be bound to a table (they put it as enforced referential integrity), but wanted to allow the users the ability to add values to the dropdown on the fly.&amp;nbsp; The idea that I came up with was to put a button on the form to allow a second form to be opened, allow a new entry to be entered and submitted to the reference table that drove the dropdown, and to automatically close that form.&amp;nbsp;&amp;nbsp; The issue was that the new value was not automatically available in the dropdown of the original form.&amp;nbsp;&amp;nbsp; It's easy enough to put a second button on the form to requery all datasources, but that wasn't very elegant.&amp;nbsp;&amp;nbsp;&amp;nbsp; I pinged our internal guru group and got a good response from &lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-theme-font: minor-fareast; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;Alex Vaynshteyn, that I've posted the meat from below.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;Use “submit via code” in the secondary form; after submitting the new record, do something similar to this: &lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // submit the secondary form (the one that adds records)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;masterForm = Application.XDocuments(0);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;masterForm.DataObjects("MyDataConnection").Query();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;// close the secondary form&lt;/SPAN&gt;&lt;SPAN lang=RU style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial; mso-ansi-language: RU"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;I have a few concerns about the approach above, that will require some refinement.&amp;nbsp;&amp;nbsp; First and foremost, the way you submit programmatically is like so:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;XDocument.DataAdapters(“&lt;I&gt;nameOfYourDataAdapter”&lt;/I&gt;).Submit();&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;FONT color=#000000&gt;The way you programmatically close a form is like so:&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;FONT face="Times New Roman" color=#000000 size=3&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: Calibri; mso-ansi-language: EN-US; mso-fareast-theme-font: minor-latin; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;FONT color=#000080&gt;Application.XDocuments.Close(XDocument);&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: Calibri; mso-ansi-language: EN-US; mso-fareast-theme-font: minor-latin; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: Calibri; mso-ansi-language: EN-US; mso-fareast-theme-font: minor-latin; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;FONT face="Times New Roman" color=#000000 size=3&gt;&lt;FONT face=Arial size=2&gt;Why I think this is not fully baked is that it's possible to have multiple forms open at once, and how you get the right index value in the Application.XDocuments() collection can be a challenge.&amp;nbsp;&amp;nbsp; When I asked Alex about this in more detail he referred me to documentation on the XDocuments object model to learn more about how to reference the collection members by name instead of index.&amp;nbsp;&amp;nbsp; I have not dug into this any deeper, but invite you to by following this link&lt;/FONT&gt; &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipsdk/html/xdproItem_2_HV01021295.asp"&gt;&lt;FONT face=Arial size=2&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipsdk/html/xdproItem_2_HV01021295.asp&lt;/FONT&gt;&lt;/A&gt;&amp;nbsp;&lt;FONT face=Arial size=2&gt;and learning more.&lt;/FONT&gt;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: Calibri; mso-ansi-language: EN-US; mso-fareast-theme-font: minor-latin; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;FONT face="Times New Roman" color=#000000 size=3&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: Calibri; mso-ansi-language: EN-US; mso-fareast-theme-font: minor-latin; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;FONT face="Times New Roman" color=#000000 size=3&gt;Newflash!&amp;nbsp; A useful post from a reader (Crazy Raymond) in response to this article:&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: Calibri; mso-ansi-language: EN-US; mso-fareast-theme-font: minor-latin; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;FONT size=2&gt;
&lt;P&gt;One thing concerning your article: "Adding Data to Dropdowns and Requerying in One Step". You were worred about using XDocuments(0). I don't think you have to use the collection at all. The XDocument object refers to the current form automatically. So, you can just use:&lt;/P&gt;
&lt;P&gt;XDocument.DataObjects("MyDataAdapter").Query() ;&lt;/P&gt;
&lt;P&gt;for a secondary data connection.&lt;/P&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=526729" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/timpash/archive/tags/Code+Samples/default.aspx">Code Samples</category></item><item><title>More on Programmatically E-Mailing via InfoPath Code</title><link>http://blogs.msdn.com/timpash/archive/2006/02/06/More-On-Programmatic-EMail.aspx</link><pubDate>Tue, 07 Feb 2006 00:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:525989</guid><dc:creator>timpash</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/timpash/comments/525989.aspx</comments><wfw:commentRss>http://blogs.msdn.com/timpash/commentrss.aspx?PostID=525989</wfw:commentRss><description>&lt;p&gt;Folks, &lt;/p&gt;
&lt;p&gt;In this post &lt;a href="/timpash/archive/2005/11/03/Alternate_Ways_To_Send_Mail.aspx"&gt;http://blogs.msdn.com/timpash/archive/2005/11/03/Alternate_Ways_To_Send_Mail.aspx&lt;/a&gt;&amp;nbsp;I was a bit lax in getting the novice to a 100% solution.&amp;nbsp;&amp;nbsp; What I left out is that most often a user is going to want to pluck values out of the form and then use those values as recipients or in the text strings that comprise the body or the subject line.&amp;nbsp;&amp;nbsp;&amp;nbsp; The way you do that is by defining variables in the code, and then setting those variables to values in the XML from the main form.&amp;nbsp;&amp;nbsp; For example, let's say you have a text field called&amp;nbsp;username that is nested directly below MyFields in the datasource.&amp;nbsp;&amp;nbsp;&amp;nbsp; Using&amp;nbsp;JScript you'd&amp;nbsp;use a line&amp;nbsp;like this to declare the variable and set the value:&lt;/p&gt;
&lt;p&gt;var objUserName = XDocument.DOM.selectSingleNode("/my:myFields/my:username");&lt;/p&gt;
&lt;p&gt;Then, later on in the code you'd do something like an objOutlookMsg.Receipts.Add(objUserName.text).&lt;/p&gt;
&lt;p&gt;The idea is to set a variable to the node that you care about, then pull out the text attribute of the node when you need it.&amp;nbsp; Hope that's a little clearer!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=525989" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/timpash/archive/tags/Code+Samples/default.aspx">Code Samples</category></item><item><title>Getting InfoPath and BizTalk to Play Nicely Together</title><link>http://blogs.msdn.com/timpash/archive/2006/02/06/InfoPath-And-BizTalk.aspx</link><pubDate>Tue, 07 Feb 2006 00:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:525977</guid><dc:creator>timpash</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/timpash/comments/525977.aspx</comments><wfw:commentRss>http://blogs.msdn.com/timpash/commentrss.aspx?PostID=525977</wfw:commentRss><description>&lt;p&gt;Folks,&lt;/p&gt;
&lt;p&gt;Been a little remiss in posting for a while.&amp;nbsp;&amp;nbsp; Been busy!&amp;nbsp; In any case, I've encountered some nuances about interacting with BizTalk that I'd like to share.&amp;nbsp;&amp;nbsp;&amp;nbsp; I often talk about how BizTalk and InfoPath are perfect bedfellows in that they are both XML centric and are "designed to work together".&amp;nbsp; Well, that's kind of true, but there's a lot of headroom to grow into based on my personal experiences.&amp;nbsp;&amp;nbsp; I recently ran into a snag where I was using the techniques noted in this post &lt;a href="/timpash/archive/2006/01/13/Submit_XML_to_File_Share_Programmatically.aspx"&gt;http://blogs.msdn.com/timpash/archive/2006/01/13/Submit_XML_to_File_Share_Programmatically.aspx&lt;/a&gt;&amp;nbsp;to push data to a UNC-Path file recieve location that BizTalk would grab and go with.&amp;nbsp;&amp;nbsp; The code worked fine when I was in-house, but would fail when I was on VPN, and wouldn't work at all for my counterparts that were in other field offices.&amp;nbsp;&amp;nbsp; Turns out that when you invoke an XDocument.SaveAs(somestring) command it doesn't actually let go of the file.&amp;nbsp;&amp;nbsp; I ran into issues where BizTalk wanted to grab it before I could get through my whole submit routine and shut down the form, and that would cause InfoPath to throw an error.&amp;nbsp;&amp;nbsp; Weird thing was that the file got to where it needed to be, and BizTalk was happy, but InfoPath was complaining (and so were end-users).&amp;nbsp;&amp;nbsp; So I got the idea (with some help)&amp;nbsp;to push the file to a staging directory that BizTalk was not monitoring, and then use an ActiveXObject calling into the FileSystemObject to move the file to it's final destination.&amp;nbsp;&amp;nbsp; Sounds smart, but everytime I tried it I'd get a permission denied error.&amp;nbsp;&amp;nbsp;&amp;nbsp; The code I was running looks like this:&lt;/p&gt;
&lt;p&gt;function MoveFiletoDropLocation(filespec)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;var fso; &lt;/p&gt;
&lt;p&gt;fso = new.ActiveXObject("Scripting.FileSystemObject");&lt;/p&gt;
&lt;p&gt;fso.MoveFile(filespec, &lt;a href="file://pashllfixit//mylongunclocationthatyoudon'tneedtoknowabout//"&gt;\\pashllfixit\\mylongunclocationthatyoudon'tneedtoknowabout\\&lt;/a&gt;);&lt;/p&gt;
&lt;p&gt;fso=null;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;So I was calling the function right after the XDocument.SaveAs line, and it would throw a permissions error.&amp;nbsp;&amp;nbsp; Could not figure it out, but then thought about the problem I was seeing with BizTalk and a light came on.&amp;nbsp;&amp;nbsp; In the script, I called two different submit operations and then called this line &lt;/p&gt;
&lt;p&gt;Application.XDocuments.Close(XDocument); &lt;/p&gt;
&lt;p&gt;to shut the form down.&amp;nbsp;&amp;nbsp; I found that when I called the MoveFiletoDropLocation function right after this line it worked like a champ.&amp;nbsp; Bottom line, be careful with the XDocument.SaveAs call because that file is locked for editing and deletion until the form is closed.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=525977" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/timpash/archive/tags/Code+Samples/default.aspx">Code Samples</category></item><item><title>Programmatically Writing Files to Directories</title><link>http://blogs.msdn.com/timpash/archive/2006/01/13/Submit-XML-to-File-Share-Programmatically.aspx</link><pubDate>Fri, 13 Jan 2006 17:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:512501</guid><dc:creator>timpash</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/timpash/comments/512501.aspx</comments><wfw:commentRss>http://blogs.msdn.com/timpash/commentrss.aspx?PostID=512501</wfw:commentRss><description>&lt;P&gt;Ok, so it's easy to send an e-mail, post to a web service or post to a WSS/SPS Form Library using the canned data connections.&amp;nbsp;&amp;nbsp; That's all fine and well.&amp;nbsp;&amp;nbsp; It's not easy however to push a file to a file directory, either locally or to a file share somewhere on the intranet.&amp;nbsp;&amp;nbsp; I had a problem recently where we needed to post an InfoPath XML file somewhere that BizTalk could grab and then do something with it.&amp;nbsp; Like I said, it's easy to push a file into a form library, and theoretically the form library should be referenceable via a UNC path.&amp;nbsp; Oddly, the UNC path works fine from a remote machine, but won't work on the server.&amp;nbsp;&amp;nbsp; Because I have BizTalk and WSS co-located on the same box, I was stuck.&amp;nbsp;&amp;nbsp; So here are some code samples on how to push files to the file system.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I was under the impression that if you used any code on the submit button, you could *only* use code and not use things like rules and data connections.&amp;nbsp;&amp;nbsp; Turns out that isn't entirely true, you can't mix rules and code, but&amp;nbsp;you can save time and&amp;nbsp;reference the data connections in code&amp;nbsp;.&amp;nbsp;&amp;nbsp; These samples require security to be applied to the solution in order for them to work, I set the solution to be full-trust explicitly.&lt;/P&gt;
&lt;P&gt;function SubmitMe::OnClick(eventObj) &lt;/P&gt;
&lt;P&gt;{ &lt;/P&gt;
&lt;P&gt;//Hard coded UNC Path.&lt;/P&gt;
&lt;P&gt;var strDataCache="&lt;A&gt;\\\\pashllfixit\\siebelfiledrop\\forreporting&lt;/A&gt;"; &lt;/P&gt;
&lt;P&gt;var oTeamMember = XDocument.DOM.selectSingleNode("//my:TeamMember"); &lt;/P&gt;
&lt;P&gt;var oMonth = XDocument.DOM.selectSingleNode("//my:Month"); &lt;/P&gt;
&lt;P&gt;var oYear = XDocument.DOM.selectSingleNode("//my:Year"); &lt;/P&gt;
&lt;P&gt;strDataCache = strDataCache + "\\" + oTeamMember.text + " " + oMonth.text + " " + oYear.text + ".xml"; &lt;/P&gt;
&lt;P&gt;try { &lt;/P&gt;
&lt;P&gt;XDocument.SaveAs(strDataCache); &lt;/P&gt;
&lt;P&gt;} &lt;/P&gt;
&lt;P&gt;catch (ex) &lt;/P&gt;
&lt;P&gt;{ &lt;/P&gt;
&lt;P&gt;XDocument.UI.Alert("Document submit to file share failed."); &lt;/P&gt;
&lt;P&gt;} &lt;/P&gt;
&lt;P&gt;XDocument.DataAdapters("Main submit").Submit(); &lt;/P&gt;
&lt;P&gt;eventObj.ReturnStatus=true; &lt;/P&gt;
&lt;P&gt;XDocument.UI.Alert("Your success message here!"); &lt;/P&gt;
&lt;P&gt;Application.XDocuments.Close(XDocument); &lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=512501" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/timpash/archive/tags/Code+Samples/default.aspx">Code Samples</category></item><item><title>Getting a Unique Value for a Field</title><link>http://blogs.msdn.com/timpash/archive/2005/12/09/Populating-A-Unique-Value-Into-A-Field-Using-Web-Services.aspx</link><pubDate>Fri, 09 Dec 2005 21:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:502126</guid><dc:creator>timpash</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/timpash/comments/502126.aspx</comments><wfw:commentRss>http://blogs.msdn.com/timpash/commentrss.aspx?PostID=502126</wfw:commentRss><description>&lt;P&gt;I've been asked multiple times on how to get a guaranteed unique value for a field in a form.&amp;nbsp;&amp;nbsp; It normally comes up in the context of a tracking id, or a request id - something that you know will be unique and will be a way to recall that entry at some point in the future.&amp;nbsp;&amp;nbsp; Because of the nature of InfoPath and the fact that multiple people can be accessing the form at a time, this is not so easy to do.&amp;nbsp;&amp;nbsp; I posed the question to the hardcore gurus within Microsoft and got a fairly decent feel for how to do this.&amp;nbsp;&amp;nbsp;&amp;nbsp; Both methods use a simple SQL table that has one field in it that holds a value.&amp;nbsp;&amp;nbsp; In one solution (the one I'm most comfortable with), two web&amp;nbsp;methods&amp;nbsp;are configured inside of one service.&amp;nbsp;&amp;nbsp; The first method&amp;nbsp;indexes the current value by one, and the second&amp;nbsp;method retrieves that value.&amp;nbsp;&amp;nbsp;I'll give you the basics of that web service, but you'll need to have some comfort level with building web services in general in order to get from point a to point b.&amp;nbsp;&amp;nbsp; The 2nd method uses only one web method within a web service, and that&amp;nbsp;method calls into a stored procedure on SQL that basically does something similar - it indexes the current value by one and then retrieve the value.&amp;nbsp;&amp;nbsp; Below are the basic steps that you need to undergo.&lt;/P&gt;
&lt;P&gt;1. Build a table in SQL, give it one field - call it MyUniqueID - of type int that is a primary key, but not an identity.&lt;/P&gt;
&lt;P&gt;2. In Visual Studio 2003, you need to set up a new project, under Visual Basic of the type of an ASP.NET Web Service.&lt;/P&gt;
&lt;P&gt;3. Under location, give it whatever location you want.&amp;nbsp;&amp;nbsp; You'll note if you are configuring this web service on the same machine that is running WSS or Portal, you'll need to exclude the path to this web service from being a managed path.&lt;/P&gt;
&lt;P&gt;4. Drag and drop SqlDataAdapter from the toolbox into the service1.asmx.vb design space.&amp;nbsp; Configure the connection to the database mentioned in step 1, and then tell it to Use SQL Statements on the page that comes next.&amp;nbsp; Click on Query Builder, select the table you built and select the MyUniqueID field.&amp;nbsp; When you finish the wizard, you'll have SqlDataAdapter1 and SqlConnection1 on the design space.&lt;/P&gt;
&lt;P&gt;5. Rename SqlDataAdapter1 to DA, rename SqlConnection1 to CN.&lt;/P&gt;
&lt;P&gt;6. Right click on DA, choose Generate Dataset, choose new and check box to Add this dataset to the designer.&amp;nbsp; Rename it to DS.&lt;/P&gt;
&lt;P&gt;7. Choose to view Code from the view menu.&lt;/P&gt;
&lt;P&gt;8. Add at the top&amp;nbsp;of the code: Imports System.Data.SqlClient&lt;/P&gt;
&lt;P&gt;9. Paste in this code snippet, which contains two distinct web methods, &amp;nbsp;below the commented out Hello World sample.&lt;/P&gt;
&lt;P&gt;&amp;lt;WebMethod()&amp;gt;_&lt;/P&gt;
&lt;P&gt;Public Function UpdateID (ByVal newDS As DataSet)&lt;/P&gt;
&lt;P&gt;da.Fill(newDS)&lt;/P&gt;
&lt;P&gt;Dim intCurVal = newDs.Tables(0).Rows(0).Item(0)&lt;/P&gt;
&lt;P&gt;intCurVal +=1&lt;/P&gt;
&lt;P&gt;newDs.Tables(0).Rows(0).Item(0) = intCurVal&lt;/P&gt;
&lt;P&gt;da.Update(newDS)&lt;/P&gt;
&lt;P&gt;End Function&lt;/P&gt;
&lt;P&gt;&amp;lt;WebMethod()&amp;gt;_&lt;/P&gt;
&lt;P&gt;Public Function GetNewID() As DataSet&lt;/P&gt;
&lt;P&gt;da.Fill(ds)&lt;/P&gt;
&lt;P&gt;Return ds&lt;/P&gt;
&lt;P&gt;End Function&lt;/P&gt;
&lt;P&gt;10.&amp;nbsp; It's fairly self-explanatory what the web&amp;nbsp;methods do.&amp;nbsp;&amp;nbsp; One increments the value and one retrieves that value.&amp;nbsp;&amp;nbsp; Piece of cake right? :-)&lt;/P&gt;
&lt;P&gt;11.&amp;nbsp; Hitting F5 will build the solution, and you should be presented with the two web methods, one called GetNewID and one called UpdateID.&amp;nbsp; The GetNewID method can be called from here, the UpdateID cannot.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;So assuming you've got this far, it pretty easy to build out the rest of the solution.&amp;nbsp;&amp;nbsp; In the form you are building, you will hook both of the services to be called on open.&amp;nbsp;&amp;nbsp; You'll set a conditional on open that looks at the unique reference field.&amp;nbsp; If it's empty, you'll call the UpdateID service, then you'll call the GetNewID service, and then you'll set the unique reference field to the value of MyUniqueID that you pull from the GetNewID web service, which will look like a secondary datasource in your solution.&amp;nbsp;&amp;nbsp; It's important not to call those services when the form is opened (you should clear those check boxes), but rather only to do it on the conditional rule that fires when the form opens.&amp;nbsp;&amp;nbsp; One last trick that is that when you are plugging in the web services, you might need to put a sample value on the UpdateID service&amp;nbsp;to make it work.&amp;nbsp;&amp;nbsp; I put in a zero on the Set Sample Value - I'm not sure you absolutely need to do that or not.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will probably append this file with more information the alternative method of using a SQL Stored Procedure sometime in the near future.&amp;nbsp;&amp;nbsp; I need to get more comfortable with that solution first however.&amp;nbsp;&amp;nbsp; Kudos to Scott Heim and Joel Alley for their help in bringing me up to speed with this stuff.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=502126" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/timpash/archive/tags/Code+Samples/default.aspx">Code Samples</category></item></channel></rss>