ADO and hb_serialize()

ADO and hb_serialize()

Postby AHF » Fri Oct 09, 2015 2:21 pm

I'm trying to save an array with hb_serialize in a TEXT field ( MySql ) but I get an error.

The statement is:
Code: Select all  Expand view

 UPDATE OUTPUTS SET ACAMPOS = 'A       )NI       NI       NI       NI       NI       NI       NI       NI       NI          NI      
NI       NI       NI      
NI       NI       NI       NI       NI       NI       NI       NI       NI       NI       NI       NI       NI       NI       NI       NI       NI       NI       NI        NI       !NI       "NI       #NI       $NI       %NI       &NI       '
NI       (NI       )' WHERE HBRECNO = 1



Anyone knows a solution ?
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO and hb_serialize()

Postby James Bott » Fri Oct 09, 2015 3:55 pm

Antionio,

Can you just use:

ASave( aArray ) --> cText

ARead( cText ) --> aArray

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: ADO and hb_serialize()

Postby AHF » Fri Oct 09, 2015 4:34 pm

James,

Thanks but its the same problem I cant save such a string.
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO and hb_serialize()

Postby James Bott » Fri Oct 09, 2015 4:47 pm

Do you mean it is too large? Something else?

I'm not sure what the example you posted is. It seems to be more than just a string of array data. I also see single quotes which will give problems with SQL. You have to replace single quotes with two single quotes (not a double quote).

I would suggest first testing with a simple array without any special characters.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: ADO and hb_serialize()

Postby AHF » Fri Oct 09, 2015 5:17 pm

James,

With Asave :

Code: Select all  Expand view
'UPDATE OUTPUTS SET ACAMPOS = 'AË * N 1N 2N 3N 4N 5N 6N 7N 8N 9N 10N 11N 12N 13N 14N 15N 16N 17N 18N 19N 20N 21N 22N 23N 24N 25N 26N 27N 28N 29N 30N 31N 32N 33N 34N 35N 36N 37N 38N 39N 40N 41N 42' WHERE HBRECNO = 72


Same problem it errors!

If I try ADO :Update() recordset becomes nuts.

Ill try fmimenc()
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO and hb_serialize()

Postby James Bott » Fri Oct 09, 2015 8:05 pm

I still see a special character in the second position. I don't know enough about SQL to know if that is an issue.

When I said something simple I meant REALLY simple. How about an array of three characters? E.G. A,B,C.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: ADO and hb_serialize()

Postby AHF » Sat Oct 10, 2015 1:15 pm

James,

I need to save an array of strings or numbers.

I tried convert it to base64 it saves but then I cant load it again.

Any ideas?
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO and hb_serialize()

Postby AHF » Sat Oct 10, 2015 3:09 pm

James,

This seems to work.

Code: Select all  Expand view

FUNCTION HB_SERIALIZE( aArray)
RETURN CMIMEENC( ASAVE( aArray ) )

FUNCTION HB_DESERIALIZE( xArray )
RETURN AREAD( CMIMEDEC(  xArray ) )
 
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO and hb_serialize()

Postby James Bott » Sat Oct 10, 2015 3:42 pm

Great news!

What does CHIMEDEC() do?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: ADO and hb_serialize()

Postby AHF » Sat Oct 10, 2015 5:23 pm

James,


(De) / Encode a string to MIME.
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO and hb_serialize()

Postby byron.hopp » Mon Oct 19, 2015 3:52 am

All,

There is a MimeClip.prg in my \\fwh\source\function directory, seems to have two functions:

fMimeDec()
fMimeEnc()

Would this help?

Byron ...
Thanks,
Byron Hopp
Matrix Computer Services
byron.hopp
 
Posts: 382
Joined: Sun Nov 06, 2005 3:55 pm
Location: Southern California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 51 guests