Hello,
I'm looking for a generic way to import XML documents into a local
SQLCE database (on Pocket PC).
To complicate, the local SQLCE database has more fields in the tables
than the XML document has nodes, and I would like to have a generic
tool (I need to import about 35 tables).
I'm trying something below:
// Create a local dataset from the XML file
DataSet ds = new DataSet();
ds.ReadXml("customer.xml");
ds.Tables[0].TableName = "CUSTOMER";
// Create a data adapter
SqlCeDataAdapter da = new SqlCeDataAdapter("SELECT * FROM CUSTOMER",
m_con);
// And the command builder
SqlCeCommandBuilder cb = new SqlCeCommandBuilder(da);
da.InsertCommand = cb.GetInsertCommand();
da.Update(ds, "CUSTOMER");
The problem that I have above, is that the DataAdapter has too many
rows for the provided data, and the XML document is not imported
(Missing SourceTable mapping), but to be honest, I'm not very sure
whether this is good code...
Any help for this junior programmer is greatly appriciated...
Cheers,
Locusta