Solved

How to backup dataset (import/export from database)

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 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

21 Experts available now in Live!

Get 1:1 Help Now