XML to SQLce

G

Guest

Ok, I have found a way to copy XML data to SQL however when I try to
reproduce the code for SQLce I have a little problem. The major method that
I required is NOT supported by .net compact framework. In short my procedure
does the following steps.

Load the XML data into a dataset.
Create an SQLce dataset that will pull all the columns for the table you
want to insert the XML data into.
Create an insert command for the SQLce dataset.
Clear the SQLce dataset.
Copy the XML dataset to the SQLce dataset
Save the SQLce dataset.

As I said the method DataSet.Copy is not supported, does anybody have a
workaround or know of another way to save an XML dataset into the SQLce
database?


Thanks in advance.
 
D

Darren Shaffer

you'll get better performance if you just iterate through the tables
in your dataset and insert the data into SQL CE using a parameterized,
prepared query. using the data adapter is convenient, but the performance
penalty outweighs the convenience in my experience.
--
Darren Shaffer
..NET Compact Framework MVP
Principal Architect
Connected Innovation
www.connectedinnovation.com
 
I

Ilya Tumanov [MS]

Here's what you can do:



1. Load XML into the DataSet.

2. Create SQL CE database with schema matching this DataSet.

3. Insert data from DataSet into SQL CE database.



Or (faster, uses less memory, but way harder to implement):



1.. Create SQL CE database with schema matching this XML.
2.. Use XmlTextReader to read XML element by element.
3.. Insert data into the SQL CE as you read it from XML.
There's no need to use DataSet.Copy() to do any of these, DataSet is not
even involved in a second case.

If you use NG search (see below) you can find a code sample for option with
DataSet.

No DataSet.Copy used in it, of course.


Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 
E

Earl

I did it like this:

Created a dataset
Created two streamwriters
Created two XMLReaders
Streamed the Schema to the XMLReader object
Streamed the XML to the other XMLReader object
Used dataset ReadXMLSchema to load the Schema
Used dataset ReadXML to load the XML
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top