Infopath 2010 VB Error

Sharepoint 2010
Infopath 2010

I am trying to write a script based upon

I get the following error when debugging the script, and Error 5337 when trying to run the form on the website. :

System.InvalidOperationException was unhandled by user code
  Message="Schema validation found non-data type errors."
       at Microsoft.MsoOffice.InfoPath.MsxmlInterop.MsxmlDocument.ThrowExceptionFromMsxmlInteropError(MsxmlInteropError eError)
       at Microsoft.MsoOffice.InfoPath.MsxmlInterop.MsxmlDocument.ThrowExceptionFromHresult(Int32 hrError)
       at Microsoft.MsoOffice.InfoPath.MsxmlInterop.MsxmlNodeImpl.AppendChild(String strXml)
       at Microsoft.Office.InfoPath.MsxmlWriter.Close()
       at System.Xml.XmlWellFormedWriter.Close()
       at System.Xml.XPath.XPathNavigator.AppendChild(XmlReader newChild)
       at System.Xml.XPath.XPathNavigator.AppendChild(XPathNavigator newChild)
       at programming_Test.FormCode.AddItem(String Diocesan_PIN, String Diocesan_Name, String Congregation_Pin, String Congregation_Name) in \\junia\Users$\Dad\My Documents\InfoPath Projects\programming Test\FormCode.vb:line 80
       at programming_Test.FormCode.CTRL6_5_Clicked(Object sender, ClickedEventArgs e) in \\junia\Users$\Dad\My Documents\InfoPath Projects\programming Test\FormCode.vb:line 45
       at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
       at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)
The Code is Attached

Imports Microsoft.Office.InfoPath
Imports System
Imports System.Xml
Imports System.Xml.XPath

Namespace programming_Test
    Public Class FormCode
        ' Member variables are not supported in browser-enabled forms.
        ' Instead, write and read these values from the FormState
        ' dictionary using code such as the following:
        ' Private Property _memberVariable() As Object
        '     Get
        '         _memberVariable = FormState("_memberVariable")
        '     End Get
        '     Set
        '         FormState("_memberVariable") = value
        '     End Set
        ' End Property

        ' NOTE: The following procedure is required by Microsoft InfoPath.
        ' It can be modified using Microsoft InfoPath.
        Private Sub InternalStartup(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Startup
            AddHandler DirectCast(EventManager.ControlEvents("CTRL6_5"), ButtonEvent).Clicked, AddressOf CTRL6_5_Clicked
        End Sub

        Public Sub CTRL6_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
            Dim secDSNav As XPathNavigator = DataSources("pinlist").CreateNavigator()
            ' Retrieve the rows of the secondary data source
            Dim rows As XPathNodeIterator = secDSNav.Select( _
            "/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW", _

            ' Loop through the rows of the secondary data source and fill the repeating table
            While rows.MoveNext()
                Dim Diocese_PIN As String = rows.Current.SelectSingleNode( _
                "/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Diocesan_x0020_PIN", NamespaceManager).Value
                Dim Diocese_Name As String = rows.Current.SelectSingleNode( _
                "/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Title", NamespaceManager).Value
                Dim Congregation_PIN As String = rows.Current.SelectSingleNode( _
                "/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:PIN", NamespaceManager).Value
                Dim Congregation_Name As String = rows.Current.SelectSingleNode( _
                "/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Parish_x0020_Name", NamespaceManager).Value

                AddItem(Diocese_PIN, Diocese_Name, Congregation_PIN, Congregation_Name)
            End While

            ' Remove the first empty item from the repeating table
        End Sub
        Private Sub AddItem( _
ByVal Diocesan_PIN As String, ByVal Diocesan_Name As String, ByVal Congregation_Pin As String, ByVal Congregation_Name As String)

            Dim doc As XmlDocument = New XmlDocument()
            Dim group As XmlNode = doc.CreateElement("group2", _

            Dim field As XmlNode = doc.CreateElement("Diocesan_PIN", _
            Dim node As XmlNode = group.AppendChild(field)
            node.InnerText = "Diocesan PIN"

            field = doc.CreateElement("Diocesan_Name", _
            node = group.AppendChild(field)
            node.InnerText = "Diocese"

            field = doc.CreateElement("Congregation_PIN", _
            node = group.AppendChild(field)
            node.InnerText = "Conregation PIN"

            field = doc.CreateElement("Congregation_Name", _
            node = group.AppendChild(field)
            node.InnerText = "Conregation Name"


            MainDataSource.CreateNavigator().SelectSingleNode( _
            "/my:myFields/my:group1", _

        End Sub
        Private Sub DeleteFirstEmptyItem()

            Dim domNav As XPathNavigator = MainDataSource.CreateNavigator()
            Dim itemNav As XPathNavigator = domNav.SelectSingleNode( _
            "/my:myFields/my:group1/my:group2[1]", _

            If itemNav IsNot Nothing Then
            End If
        End Sub
    End Class
End Namespace

Open in new window

Who is Participating?
JesusFreak42Author Commented:
I will be trying this out on my own. The project was able to move forward without it, but I'fd like this for furture projects.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.