Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Transformation changes date value
Message
De
09/09/2010 10:39:58
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Web Services
Titre:
Transformation changes date value
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01480677
Message ID:
01480677
Vues:
98
I have this method which scans all fields in a dataset and replaces them with an empty value if it is NULL.
        ' Adjust a dataset to avoid null values
        ' expO1 Dataset
        Public Function AdjustDataSetToAvoidNullValue(ByVal toDataSet As DataSet) As DataSet
            Dim lcColumn As String = ""
            Dim ldDate As Date = oApp.GetEmptyDate()
            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
                        lcColumn = loColumn.ColumnName

                        If IsDBNull(loRow.Item(lcColumn)) Then

                            Select Case loColumn.DataType.ToString

                                Case "System.DateTime"
                                    loRow.Item(lcColumn) = ldDate

                                Case "System.Integer"
                                    loRow.Item(lcColumn) = 0

                                Case "System.Decimal"
                                    loRow.Item(lcColumn) = 0

                                Case "System.Boolean"
                                    loRow.Item(lcColumn) = False

                                Case "System.String"
                                    loRow.Item(lcColumn) = ""

                                Case "System.Int32"
                                    loRow.Item(lcColumn) = 0

                                Case Else
                                    DataErrorControlledByTheFramework("In " + _
                                     "DataXML.AdjustDataSetToAvoidNullValue(), the type " + _
                                     loColumn.DataType.ToString + " has not been defined.")

                            End Select

                        End If

                        ' The loXslCompiledTransform.Transform() cannot support NULL.
                        ' So, we have to remove them from the value.
                        loRow.Item(lcColumn) = oApp.StrTran(loRow.Item(lcColumn), Chr(0), "")

                    Next

                Next

            Next

            Return toDataSet
        End Function
I just found today that if I have an empty date, such as 1899-12-30T00:00:00-05:00, that the line which initializes loRow.Item() to something will replace the value with 2010-09-09T00:00:00-04:00.

oApp.StrTran() is doing this:
        ' Equivalent of VFP StrTran()
        ' expC1 String
        ' expC2 Search for specific character
        ' expC3 Replace
        Public Function StrTran(ByVal tcSearchIn As String, ByVal tcSearchFor As String, _
         ByVal tcReplace As String) As String
            Dim loStringBuilder As StringBuilder = New StringBuilder(tcSearchIn)
            Return loStringBuilder.Replace(tcSearchFor, tcReplace).ToString()
        End Function
I really do not understand why calling StrTran() will change the value. This only happens when I have an empty value in the date. I just found out about it when sending some XML data from a Web Service method().

Anyone knows anything about it?
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform