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.