XML to SQLce

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Not to seem ungratefull but you left out the magic step, how do I save the ds
to the SQLce database? I do not know of any way to bind a XML dataset to a
SQLce database without coping it into another dataset that is already bound
to the SQLce database.

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
 
Please see this for sample:
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compac
tframework/msg/22af9850f0f8dcf7?hl=en

Also note there's no such thing as "DataSet bound to XML" or "DataSet bound
to SQL CE".
There's just DataSet which has been populated from whatever data source and
which can be saved to whatever data source, same or different.

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.compac
tframework?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).

--------------------
 
Read Ilya's article for sure, but here is one way of doing it (which others
may not like, but was fine for my purposes). Note that you'll have to use
reflection to set your AppPath. You may also want to check for file
existence and delete before trying to write.

'writing only the XML data
Dim strPathToXML As String = AppPath & "\replsettings.xml"
ds.WriteXml(strPathToXML)

'writing only the schema
Dim strPathToSchema As String = AppPath & "\replschema.xsd"
ds.WriteXmlSchema(strPathToSchema)
 
Back
Top