Page 1 of 1

[SOLVED] SaveToStream and SaveToFile

Posted: 18.12.2016, 21:13
by Prometeus
Hello,


I've been using the last SVNs and now I realized that when using 'FIELD.SaveToStream' or 'FIELD.SaveToFile' functions in both 'TZQuery' and 'TZReadOnlyQuery' components only the first byte has been saved by them in the stream or file, where 'FIELD' is a BLOB field. I am using Delphi 10.1 Berlin Update 2 now but this problem seem not occur with Delphi 7.

Can this be confirmed?

Thanks!

Joao Lira.

Re: SaveToStream and SaveToFile bug

Posted: 20.12.2016, 09:44
by marsupilami
Hello Joao,

hmmm - I assume, you are trying to save a text field? Which driver do you use?
With best regards,

Jan

Re: SaveToStream and SaveToFile bug

Posted: 20.12.2016, 11:04
by Prometeus
Hello, Jan,


Yes, the BLOB field is plain text. I am using Zeos with Firebird 3.01. I was writing my first Intraweb application when this problem occured and I thought it had been caused by the latest release of Intraweb until I realized it was a Zeos issue. Is there already a notification about such a bug?

Thank you!


Joao Lira.

Re: SaveToStream and SaveToFile bug

Posted: 20.12.2016, 16:54
by marsupilami
Hello Joao,

currently there is no bug report besides yours about this problem. Could you maybe create a small test case? An example program and an example database? That would help me in tracking down the issue. This way I exactly see how your TZConnection is configured and how your database is set up.

With best regards,

Jan

Re: SaveToStream and SaveToFile bug

Posted: 20.12.2016, 22:35
by Prometeus
Hello, Jan,


Ok, I'll try to make a small application to show the problem.

Thanks!


Joao Lira.

Re: SaveToStream and SaveToFile bug

Posted: 21.12.2016, 22:28
by Prometeus
Hello, Jan,


As asked I did attach a small sample of the problem. As you will see there is a small Firebird 3.0 database with one table with two fields, one of them is BLOB text. The application has one unit with A 'Memo' and a 'Button'. When the button is clicked the only record is loaded in a 'TZQuery', and next the BLOB field 'ZQ1MEMO_TEST' is saved into a stream and loaded into the 'Memo' using a 'stream' variable. If you check out the database you'll see that the 'MEMO_TEST' field has a string of many characters but only the first one is loaded into the stream and into the 'Memo'. Here is the bug.

Thank you for any light here!

Regards,
Joao Lira.

Re: [BUG] SaveToStream and SaveToFile

Posted: 03.01.2017, 17:04
by marsupilami
Hello Joao,

I am sorry for my late response but between christmas and new year I had to tae some holidays away from my computer ;)

I think, there is a problem in your code. Using this line, I get a lot more than 1 character shown:
Memo1.Lines.LoadFromStream(memo_stream, TUnicodeEncoding.Create);

Let's not talk about the memory leak in that line - for proper code you would have to create a TUnicodeEncoding before and destroy it later on. ;)

With best regards,

Jan

Re: [SOLVED] SaveToStream and SaveToFile

Posted: 03.01.2017, 18:59
by Prometeus
Hello, Jan,

First of all, I hope that you and your family have had a really happy holidays time.

I moved from Delphi 7 to Delphi 10.1 Berlin just a couple of months ago and I am still 'browsing' into this 'new world'... I didn't knew about this new way of calling 'LoadFromStream'.

I tested your sugestion (including creating and destroying a 'TUnicodeEncoding' variable to prevent memory leakage) and it worked. Well, fortunately it does not seem like a 'Zeos' fault.

Thank You!


Joao Lira.