This message was edited by rlc at 2005-9-13 18:51:28
I think the problem is you are not using "NEW" the create instances of the test reader and stream. If you just do...
ds.readxml(<filename>)
It will work but you may lose some of the formatting.. I am not sure the exact difference. I have a function that loads tables in a DB during install using the reader method I will paste a relvant snip below...
~rlc
EDIT: P.S. this method assumes the XML file has the schema
' load each xml file into the database
Try
Dim lSqlConnection As SqlClient.SqlConnection = New SqlClient.SqlConnection(m_ConnectString)
Dim lCommand As SqlClient.SqlCommand
Dim lBuilder As SqlClient.SqlCommandBuilder
Dim lDataAdapter As SqlClient.SqlDataAdapter
Dim lDataSet As DataSet
Dim lCurrFileName As String
Dim lCurrTableName As String
Dim lXmlReader As Xml.XmlTextReader
For Each lCurrFileName In Directory.GetFiles(lXmlPath, "*.xml")
lCurrTableName = Path.GetFileNameWithoutExtension(lCurrFileName)
If Not m_IsUpdate OrElse Array.IndexOf(m_UpdateData, lCurrTableName) <> -1 Then
' do this table
WriteEvent("Loading data from " & lCurrFileName)
lCommand = New SqlClient.SqlCommand("SELECT * FROM [" & lCurrTableName & "]", lSqlConnection)
lDataAdapter = New SqlClient.SqlDataAdapter(lCommand)
lBuilder = New SqlClient.SqlCommandBuilder(lDataAdapter)
lDataSet = New DataSet(lCurrTableName)
lXmlReader = New Xml.XmlTextReader(lCurrFileName)
lDataSet.ReadXml(lXmlReader, XmlReadMode.ReadSchema)
lDataAdapter.Update(lDataSet)
lXmlReader.Close()
End If
Next
lSqlConnection.Close()
Catch ex As SqlClient.SqlException
WriteEvent("Error inserting data: " & ex.Message)
End Try
: : I have used the DS function with the Schemea and without. What overload are you using for the ReadXML function?
: :
: : ~rlc
: :
: dim ds as new dataset
: dim fs as IO.StreamReader("FileName.XML")
: dim xr as XML.XmlTextReader(fs)
: ds.ReadXml(xr)
:
:
: