Link to home
Start Free TrialLog in
Avatar of JPERKS1985
JPERKS1985

asked on

Export DataGrid to XML or update data in the dataset and then export to XML

I need to know how to either export my datagrid directly to an xml file (preferred) or modify specific items within the dataset and then export the xml.

ASKER CERTIFIED SOLUTION
Avatar of vbturbo
vbturbo
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BTW

if u wonna know about dataset's and how to work  with dataset u might checkout this link

http://www.homeandlearn.co.uk/NET/nets12p9.html
I would think serialisation would be the way to go.... (because it just is, usually)

Pass your dataset into and outof these functions, they return the DS as text that you can save or whatever.
You may like to modify them to read and write directly to files..

      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