Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why empty date in VFP has entry in .NET?
Message
 
 
To
28/05/2004 13:38:39
Keith Payne
Technical Marketing Solutions
Florida, United States
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00907017
Message ID:
00908248
Views:
36
>>>>I retrieve a row from a VFP table, as datareader, where a date field has not entry (in VFP). But when I look at it in ASP.NET the date is there and it is 12/30/1899. I know I didn't enter any data in 1899 <g>. Who did?
>>>>
>>>>TIA.
>>>
>>>Dmitry,
>>>
>>>VFP's date type and .NET's datetime type are not exactly the same. You will have to manually convert 12/30/1899 to DbNull when you use the data.
>>>
>>>An alternative is to use a typed DataSet instead of a DataReader. You could edit the datetime column's Get accessor to return DbNull when the underlying data contains 12/30/1899.
>>
>>Keith,
>>
>>Thank you for your help. I will look up .net help on how to use DbNull (I don't know how to use it). Or I can check for the date to be greater than 1900 and consider everything before that date as empty. At this point, for this project, DataReader is my only choice.
>
>If a lot of your projects use a VFP database, it might be a good idea to sub-class the OleDbDataReader and override the GetDateTime, GetValue and GetValues methods. Simply call the base class' method, then compare to 12/31/1899 and return DbNull where appropriate.
>
>Actually, it would be a nifty little project to create a VFPClient namespace with VFP* classes, just like Sql*, Oracle* and OleDb* classes.

Great suggestion on creating sub-class of OleDbDataReader. It is a little over my head right now, since I have not yet tried to create classes based on basic .net classes. But would be good experience to try and learn from it.
Thank you very much.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform