Tuesday, March 06, 2012 3:27 PM
I have a Foxpro table that uses a Memo field to hold either string or binary data, depending on the record. I'd like to dump that table to XML using CursorToXML, so that I can import the data using .NET objects. However, the binary data does not come out right; it's truncated. I know why this is happening, of course, but I'm curious to know if there is a standard way of dealing with this. I'd like to avoid having to do some sort of conversion on both sides if possible.
Tuesday, March 06, 2012 7:15 PM
Look into the parameter descriptions.
nFlag = 4096 disables conversion of binary fields to base64 encoding.
This also means, binary fields ARE encoded base64. But there is no way to force a normal memo field to be base64 encoded, you need to select into a cursor with binary fields, eg via CAST(), before using CursortoXML, and you also can't have both text and binary data in the field, you will need to split data into two fields.
Assumed there is some boolean field named "flagfield" being .T. if the memo contains binary data and .F., if text, then
SELECT ..., CAST( iif(flagfield,memofield,.NULL.) AS Blob) AS binarymemo, CAST( iif(NOT flagfield,memofield,.NULL.) AS Memo) As memofield...INTO CURSOR curXML
Then cursortoxml that cursor.
Tuesday, March 06, 2012 8:24 PMThanks! Not sure if I can use that, but it answers my question.
Wednesday, March 07, 2012 6:51 AM
I also don't know how .NET can handle this XMl, but base64 encoding of binary data is common.