Quantcast
Viewing all articles
Browse latest Browse all 15772

VS 2019 Import large XML file into datatable: OutOfMemoryException was thrown

Hi all,
I have a large xml file (about 2Gb) and I'm trying to import it into dataset or better in SQL Server.
I read that to solve issue of memory, it's better to use XmlReader...
So I started with following code:
Code:

Dim settings As XmlReaderSettings = New XmlReaderSettings
        settings.DtdProcessing = DtdProcessing.Parse
        settings.ValidationType = ValidationType.Schema

        Dim reader As XmlReader = XmlReader.Create(TextBox1.Text, settings)

        While reader.Read
            If reader.NodeType = XmlNodeType.Element Then
                Dim aa As XmlDocument = New XmlDocument
                aa.LoadXml(reader.ReadOuterXml)

            End If

        End While

but after aa.loadXml command I obtained "out of memory" message.
How can I solve it?
What is correct procedure to manage this file?

I'm groping in the dark :confused:
Thank in advanced
gio

Viewing all articles
Browse latest Browse all 15772

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>