Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
300
ReadXMLString throws exception 'Object Reference not set to an instance of an object'
posted

 I've been trying to implement ReadXMLString method on the UltraWebTree but keep getting an 'Object Reference not set to an instance of an object' exception thrown.  Interestingly the XMl string I'm reading back in was originally generated by the WriteXMLString function with no issues.  My short code snippet follows:

     Private Sub BuildTreeDR()
        Dim ConnectionString As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ChepGAP2v2ConnectionString").ConnectionString
        Dim obConn As New SqlConnection(ConnectionString)
        Dim sql As String = "SELECT TOP 1 BookXML FROM tblTest"
        Dim XMLString As String
        Using obConn
            Dim cmd As New SqlCommand(sql, obConn)
            Try
                obConn.Open()
                XMLString = Convert.ToString(cmd.ExecuteScalar())
                ' XMLString is initialized with the XML structure at this point
                Me.UltraWebTree1.ReadXmlString(XMLString, True, True)
                obConn.Close()
            Catch ex As Exception
                ' ex.Message = "Object reference not set to an instance of an object."
                MsgBox(ex.Message)
            End Try
        End Using
    End Sub

Any insite into the problem would be greatly appreciated.

 

Parents
No Data
Reply
  • 28464
    posted

    Write/ReadXmlDoc are intended for save/restore state (although you can certainly use them in other cases). So the only way to use ReadXmlDoc is to use the very same format you've got from WriteXmlDoc before. This could be tricky. 

    I believe the standard way to bind Xml to the treeview is to use the declarative XmlDataSource control Please, take a look at the following search (binding XmlDataSource to UltraWebTree) in our forums - some of the forum threads there are a direct match for what you need.

Children