Solved

How to backup dataset (import/export from database)

Posted on 2006-07-11
4
185 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now