Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to backup dataset (import/export from database)

Posted on 2006-07-11
4
186 Views
Last Modified: 2010-04-23
Hi experts

i use a process  that retrieve datas from database (sql server 2000) into a dataset

i use dataset.writexml(filename) to export data into xml files

it works but i don't know how to import those data into the database (if the process failed for example)  because i don't know how to use the "writexml" method properly (xsd, etc...)

or maybe you have a better solution...

regards
0
Comment
Question by:Dnx_7
  • 2
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
lojk earned 500 total points
ID: 17080248
Serialisation....

    Public Function SerializeDataset(ByVal DatasetToSerialise As Data.Dataset) As String
        Dim oXS As System.Xml.Serialization.XmlSerializer
        Try
            oXS = New System.Xml.Serialization.XmlSerializer(GetType(Data.Dataset))
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
        Dim oStmW As IO.StringWriter
        oStmW = New IO.StringWriter()
      Try
            oXS.Serialize(oStmW, DatasetToSerialise)
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
        oStmW.Close()

        Return oStmW.ToString

    End Function


     Public Function DeserialiseDataset(ByVal SerializedObject As String) As DataSet
        Dim oXS As Xml.Serialization.XmlSerializer = New Xml.Serialization.XmlSerializer(GetType(Data.DataSet))
        Dim oStmR As IO.StringReader
        oStmR = New IO.StringReader(SerializedObject)
        Dim NewDataSet As Data.DataSet= CType(oXS.Deserialize(oStmR), Data.DataSet)
        oStmR.Close()
        Return NewDataSet
    End Function

Replace String Reader and Writers with Stream Readers and Writers to export into files instead of returning strings...

0
 
LVL 2

Author Comment

by:Dnx_7
ID: 17080981
thank you very much, it is exactly what i was searching for!

regards
0
 
LVL 9

Expert Comment

by:lojk
ID: 17083838
cool. happy to help, thanks for the points..

also, check out what XSLT can do for you in transforming those datasets into html tables or any other output that you like..
0
 
LVL 2

Author Comment

by:Dnx_7
ID: 17084266
i will !

thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question