I'm attempting to load an xml document from an XML column in MSSQL 2008, into an XmlDocument (see code below).
Sometimes the code will break at the xdoc.Load(xr) line with the error "Unexpected end of file and occurred". After breaking, the XmlReader has a value of "None".
While researching the problem, I saw posts that referred to a 4Kb limit on StreamReaders and figured this may be related somehow. So I cut down the size of my document (to around 4Kb) and everything worked fine.
On average, the XML documents I'm importing from the database are 20Kb.
Does anyone know how to get a 'large' amounts of XML from the database into my XmlDocument?
Expand|Select|Wrap|Line Numbers
- Dim xr As XmlReader = ExportAdapter.GetEditedCheckXML(chkId)
- Dim xdoc As New XmlDocument
- xdoc.Load(xr)
Expand|Select|Wrap|Line Numbers
- Public Shared Function GetEditedCheckXML(ByVal checkId As Integer) As XmlReader
- Dim conn As SqlConnection = New SqlConnection(CONNECTION_STRING)
- Dim comm As New SqlCommand("PS_GetModifiedXmlByCheckId", conn)
- Dim adap As New SqlDataAdapter
- comm.CommandType = CommandType.StoredProcedure
- comm.Parameters.Add("@checkId", SqlDbType.Int).Value = CInt(checkId)
- conn.Open()
- Dim xml = comm.ExecuteXmlReader()
- xml.Read()
- conn.Close()
- Return xml
- End Function