Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Handling date fields from Visual FoxPro
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Versions des environnements
Environment:
C# 2.0
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01129644
Message ID:
01129655
Vues:
11
>I have a connection to a Visual FoxPro database. When I pull in a record with a date field that is blank, the date gets set to 12/30/1899. For this project that could actually be a valid date, so I don't want to trap for that date. What do I need to do to get it to show an empty date?

There has been various threads on the topic recently. This is a known problem in the architecture. In my case, those dates are not used, so I can use this to verify if the date is blank:
        ' Return True if a date is empty
        ' expD1 Date
        Public Function EmptyDate(ByVal tdDate As Object) As Boolean
            Dim llEmpty As Boolean
            Dim ldDate As Date
            llEmpty = False

            ' Different providers handle the empty and null dates differently
            Select Case oApp.nSQLMode

                ' OleDb
                Case 1
                    ldDate = New Date(1899, 12, 30)
                    If tdDate = ldDate Then
                        llEmpty = True
                    End If

                    ' SQLClient
                Case 2
                    If tdDate Is DBNull.Value Then
                        llEmpty = True
                    End If

                    ' ODBC
                Case 3

            End Select

            Return llEmpty
        End Function
And, this to return an empty date:
        ' Return an empty date
        ' expT1 Date
        Public Function GetEmptyDate() As Date
            Return New Date(1899, 12, 30, 0, 0, 0)
        End Function
But, in your case, you might want to verify for the DBNull.value such as:
                                    If Not oRow(aField(lnCompteur2, 8)) Is DBNull.Value Then
                                        ldValue = oRow(aField(lnCompteur2, 8))
                                    Else
                                        ldValue = oApp.GetEmptyDate()
                                    End If
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform