I have xml (xsd) file. I need create db table in SQLite db, and load data from XML to this table (in C# application).
I try to use this code:
string ConnectionStr = "Data Source=mydb.sqlite;Version=3; New=True; Compress = True;";
NDbUnit.Core.INDbUnitTest Database = new NDbUnit.Core.SqlLite.SqlLiteDbUnitTest(ConnectionStr);
Database.ReadXmlSchema("AS_ACTSTAT.xsd");
Database.ReadXml("AS_ACTSTAT.xml");
Database.PerformDbOperation(NDbUnit.Core.DbOperationFlag.CleanInsertIdentity);
But I have this error (read xml schema):
SqlDbCommandBuilder.CreateSelectCommand(DataSet, string) failed for tableName = 'ActualStatus'
Schema file:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://ift.tt/tphNwY" xmlns:sch="http://ift.tt/1p5NkqA" xmlns:usch="http://ift.tt/1HERY79" xmlns:sql="urn:schemas-microsoft-com:mapping-schema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="ActualStatuses" sql:is-constant="true" >
<xs:annotation>
<xs:documentation>sostav</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="ActualStatus" maxOccurs="unbounded" sql:relation="AS_ACTSTAT">
<xs:annotation>
<xs:documentation>status</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="ACTSTATID" use="required">
<xs:annotation>
<xs:documentation>key</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="NAME" use="required">
<xs:annotation>
<xs:documentation>name
0 – non actual
1 – actual
</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
ps Also I try use SqlXml 4.0 from Microsoft (it works great with MS SQL 2008), but can't find OLEDB driver for SQLite.
Any idea? I need something like SqlXml 4.0 fo SQlite, because i dont know structure of xml file previously.
Aucun commentaire:
Enregistrer un commentaire