Insert an empty date into VFP

May 19, 2013 at 4:31 PM
Edited May 19, 2013 at 6:14 PM
Is it possible to do the equivalent of setting a fox date field to empty (e.g. INSERT INTO table (datefield) VALUES ({})) when using LINQ to VFP's InsertOnSubmit ?

Unfortunately, as I'm working in this instance with a fox system which prevents the use of nullable fields, it isn't an option to use the nullable approach (e.g. DateTime?) which would otherwise do the trick.

The answer to following MSDN thread seems to cover the SQL pass-through syntax for the empty {} date: -

How to insert Null value to foxpro tables

Thanks in advance for any suggestions,

Chris

Chris Cook :: Software Development Manager :: www.genesisit.co.uk
Design, Develop, Deliver! :: App development for smartphones, tablets, the desktop and the web
Coordinator
May 20, 2013 at 12:39 PM
No, there isn't a way to insert an empty date with the current build but I have an idea on how I can make this work. I'll let you know when I figure something out.
May 20, 2013 at 1:10 PM
Edited May 20, 2013 at 1:22 PM
Hi Tom,

Many thanks for the quick reply and if you do manage to figure something out that would be great.

With the exception of this small issue, we're finding your framework works incredibly well and it has helped us to efficiently integrate various Android and Apple iOS mobile apps into a fox based accounting system (much to the delight of the users :-).

Thanks again and kind regards,

Chris

Chris Cook :: Software Development Manager :: www.genesisit.co.uk
Design, Develop, Deliver! :: App development for smartphones, tablets, the desktop and the web
Coordinator
May 24, 2013 at 8:55 PM
I posted an update that will allow you to insert empty values. The generated insert statement was changed so that it does not include columns that have null values. This will allow VFP to determine the correct value for those columns. In your case, you will want to include “null=false” (equivalent to “set null off” in VFP) in the connection string so that the omitted columns will have empty values inserted instead of nulls. With this change you should be able to use “DateTime?” in your model to allow the insert of an empty date.

One thing to note is that when you read an empty date value from .Net you will end up with a date value of 12/30/1899 12:00:00 AM. So when you do an update your empty date will end up getting replaced with this default date. This just seems like a mess to me… but I can’t think of a way to get .Net to play nice with VFP’s empty concept.
Jun 1, 2013 at 10:09 PM
Hi Tom,

Many thanks for organising the new version which has worked a treat.

Kind regards,

Chris

Chris Cook :: Software Development Manager :: www.genesisit.co.uk
Design, Develop, Deliver! :: App development for smartphones, tablets, the desktop and the web