Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with converting dataset to Xml
Message
From
01/04/2007 10:09:28
 
 
To
01/04/2007 09:55:30
General information
Forum:
ASP.NET
Category:
Databases
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01210955
Message ID:
01210956
Views:
19
Ok, here is how I adjusted it:
        ' Convert a DataSet into an Xml
        ' This functions make it so the schema is included
        ' expO1 DataSet
        Public Function DataSetToXml(ByVal toDataSet As DataSet) As String
            Dim lcXml As String = ""
            Dim loMemorySteam As New MemoryStream()

            ' Adjust the dataset to avoid null values
            toDataSet = AdjustDataSetToAvoidNullValue(toDataSet)

            toDataSet.WriteXml(loMemorySteam, XmlWriteMode.WriteSchema)
            loMemorySteam.Seek(0, SeekOrigin.Begin)
            Dim lcStreamReader As New StreamReader(loMemorySteam)
            lcXml = lcStreamReader.ReadToEnd()
            Return lcXml
        End Function

        ' Adjust a dataset to avoid null values
        ' expO1 Dataset
        Public Function AdjustDataSetToAvoidNullValue(ByVal toDataSet As DataSet) As DataSet
            Dim loColumn As DataColumn
            Dim loRow As DataRow
            Dim loTable As DataTable

            For Each loTable In toDataSet.Tables
                For Each loRow In loTable.Rows
                    For Each loColumn In loTable.Columns
                        If IsDBNull(loRow.Item(loColumn.ColumnName)) Then

                            Select Case loColumn.DataType.ToString

                                Case "System.DateTime"

                                    ' Get the proper definition as per the current scope
                                    If oProcess Is Nothing Then
                                        loRow.Item(loColumn.ColumnName) = oProcess.oApp.GetEmptyDate()
                                    Else
                                        loRow.Item(loColumn.ColumnName) = oApp.GetEmptyDate()
                                    End If

                                Case "System.Integer"
                                    loRow.Item(loColumn.ColumnName) = 0

                                Case Else
                                    loRow.Item(loColumn.ColumnName) = ""

                            End Select

                        End If
                    Next
                Next
            Next

            Return toDataSet
        End Function
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Reply
Map
View

Click here to load this message in the networking platform