I am tasked with providing a means of exporting and importing records from one client to another. I started out using the BusinessObject.CurrentDataTable.WriteXML(Filename), and using the subsequent DataSet.ReadXML(filename), and copying the data with a BusinessObject.CopyDataFrom(DataSet.Tables(0), AppedDatatoTableFromCompleteTable) method and this worked fine. I looked through the sample XML datasource project and it appears to be using the method I had and was working well.
Then I read the post about decrpyting XML and using the Microfour XML namespace methods to generate XML files from datasets. With this the schema was placed in the file along with the versioning and built in encryption, so I decided to start working on switching to this method.
Using the MicroFour.StrataFrame.XML.XMLBasics.WriteXMLFile(Dataset, filename) this seems to generate the XML file fine.
'-- Write DataSet to XML
Dim loDS As New DataSetloDS.Tables.Add(MyBusinessObject.CurrentDataTable)
'-- Write the DataSet to XML to the SaveFileDialog's Filename
MicroFour.StrataFrame.Xml.XmlBasics.WriteXmlFile(loDS, loSaveFileDialog.FileName,
False)My problem comes with trying to read this back in using the ReadXMLFile method.
'-- Instantiate a new DS
Dim loDS As New DataSet'-- Fill the Dataset from the XML fileloDS.ReadXmlSchema(loOpenFileDialog.FileName)
'-- Declare some locals for Listing DataColumns from XML schemaDim loCol As DataColumnDim laCols As New System.Collections.Generic.List(Of DataColumn)'-- Iterate through Table(0) and build List of DataColumnsFor Each loCol In loDS.Tables(0).ColumnslaCols.Add(loCol)
Next'-- Read the XML file into the DataSetloDS = MicroFour.StrataFrame.Xml.XmlBasics.OpenXmlFile(
"1.0", loDS.Tables(0).TableName, loOpenFileDialog.FileName, laCols, False)
When it gets to the OpnXMLFile method it checks for the version of the XML and always returns -1, and writes the XMLVersion table to the xml file with no data in the XML datatable(0) where the data was.
Before xml file
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="U_NSN" msdata:CaseSensitive="False" msdata:Locale="en-US">
<xs:complexType>
<xs:sequence>
<xs:element name="U_NSN_PK" msdataataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs:string" minOccurs="0" />
<xs:element name="U_NSN_Nomenclature" type="xs:string" minOccurs="0" />
<xs:element name="U_NSN_Price" type="xs:decimal" minOccurs="0" />
<xs:element name="U_NSN_Weight" type="xs:double" minOccurs="0" />
<xs:element name="U_NSN_Volume" type="xs:double" minOccurs="0" />
<xs:element name="U_NSN_UOMFK" msdataataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs:string" minOccurs="0" />
<xs:element name="U_NSN_UserID" type="xs:string" minOccurs="0" />
<xs:element name="U_NSN_Public" type="xs:boolean" minOccurs="0" />
<xs:element name="U_NSN_cncDateTime" type="xs:dateTime" minOccurs="0" />
<xs:element name="U_NSN_FSCFK" msdataataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs:string" minOccurs="0" />
<xs:element name="U_NSN_CountryCodeFK" msdataataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs:string" minOccurs="0" />
<xs:element name="U_NSN_PartialName" type="xs:string" minOccurs="0" />
<xs:element name="U_NSN_FullName" type="xs:string" minOccurs="0" />
<xs:element name="U_NSN_CON_DATETIME" type="xs:dateTime" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<U_NSN>
<U_NSN_PK>e2579dbf-a73a-4681-bbb2-43f2c2b9eed1</U_NSN_PK>
<U_NSN_Nomenclature>Air Conditioning equipment from iceland. I think its just a bag of ice.</U_NSN_Nomenclature>
<U_NSN_Price>0.8500</U_NSN_Price>
<U_NSN_Weight>8</U_NSN_Weight>
<U_NSN_Volume>1.252</U_NSN_Volume>
<U_NSN_UOMFK>eaa6e172-5bc5-4e54-ac49-292618f6cf7e</U_NSN_UOMFK>
<U_NSN_UserID />
<U_NSN_Public>false</U_NSN_Public>
<U_NSN_cncDateTime>1800-01-01T00:00:00-06:00</U_NSN_cncDateTime>
<U_NSN_FSCFK>982d5ae6-b301-4785-83dc-39064590f594</U_NSN_FSCFK>
<U_NSN_CountryCodeFK>fd49f597-e560-4f15-b037-746c49357137</U_NSN_CountryCodeFK>
<U_NSN_PartialName>1121445</U_NSN_PartialName>
<U_NSN_FullName>4120IS1145445</U_NSN_FullName>
<U_NSN_CON_DATETIME>2007-03-08T12:56:49.693-06:00</U_NSN_CON_DATETIME>
</U_NSN>
</NewDataSet>
After the code runs to read the file
<?xml version="1.0" standalone="yes"?>
<XmlStructure>
<xs:schema id="XmlStructure" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="XmlStructure" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="XmlVersionInfo">
<xs:complexType>
<xs:sequence>
<xs:element name="xml_Version" type="xs:string" default="" minOccurs="0" />
<xs:element name="xml_ValidationKey" type="xs:string" default="" minOccurs="0" />
<xs:element name="xml_Comment" type="xs:string" default="" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="U_NSN">
<xs:complexType>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<XmlVersionInfo>
<xml_Version>1.0</xml_Version>
<xml_ValidationKey />
<xml_Comment>Created on Monday, March 19, 2007 at 12:47:05 PM
Version upgraded from 0.0.0.0 to 1.0 on Monday, March 19, 2007 at 12:47:05 PM</xml_Comment>
</XmlVersionInfo>
<U_NSN />
</XmlStructure>
What am I missing here?
Thanks,
Robin Giltner
Heh, the colon-capital 'D' gets changed to a . Heh.