Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem converting empty date to DataSet
Message
From
20/08/2013 18:37:33
 
 
To
20/08/2013 18:02:06
Joel Leach
Memorial Business Systems, Inc.
Tennessee, United States
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01580842
Message ID:
01580862
Views:
54
>>>I am returning a cursor from FoxPro using CursorToXML(lcAlias,"lcXML",1,0,0,"1"), then converting the XML to a DataSet in .NET. It works well unless the cursor includes empty dates. .NET doesn't like them. It wants NULLs, meaning the field element is excluded altogether in the XML. I can work around the issue by not including a schema, but that treats everything as a string and doesn't meet my needs. I don't want to replace the empty date fields with NULL in FoxPro. I could strip the empty fields out of the XML on the .NET side before loading the XML into a DataSet, which is ok, but I'm wondering if there is a better solution? I have read Message #1199897, but that didn't work for me.
>>>
>>>Thanks.
>>
>>Is their any reason that you don't open the VFP table with .NET and create the dataset from the VFP table?
>
>Yes. The cursor is often the result of processing data in FoxPro. It is quite a bit of existing code, so porting it over is not feasible at this time. For now, the best solution I could find is to modify the XML in VFP before returning it to .NET.
>
>* Include schema
>CursorToXML(lcAlias,"lcXML",1,0,0,"1")
>
>* .NET Dataset doesn't allow FoxPro empty dates when schema included, so strip them out
>* Allow null values in date fields
>lcXML = Strtran(lcXML, [type="xsd:date"], [type="xsd:date" minOccurs="0"])
>lcXML = Strtran(lcXML, [type="xsd:dateTime"], [type="xsd:dateTime" minOccurs="0"])
>* Replace empty dates with NULL
>lnFieldCnt = AFields(laFields, lcAlias)
>For lnField = 1 to lnFieldCnt
>	If InList(laFields[lnField, 2], "D", "T")
>		lcField = laFields[lnField, 1]
>		lcXML = Strtran(lcXML, "<" + Lower(lcField) + "/>", "")
>	EndIf 
>EndFor 
>
>Return lcXML
>
Yes, I see your point. You probably have found the best solution, given the situation.
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.
Previous
Reply
Map
View

Click here to load this message in the networking platform