Recent

Author Topic: tstream readcomponent issue  (Read 3414 times)

snorkel

  • Hero Member
  • *****
  • Posts: 817
tstream readcomponent issue
« on: July 21, 2016, 08:49:48 pm »
Hi,
I am streaming a Zeos DB component over TCP/IP and it gets received on the server just fine.
The issue I am seeing is when I have a string parameter i.e. myquery.params.parambyname('bla').asstring:= memo1.text; 
if memo1.text is 255 chars or less readcomponent works just fine.  If it's 256 chars it raises an exception about invalid variant type 12?

The zeos query component does allow params bigger than 255 so I am guessing it's something in the readcomponent.

Anyone have any ideas?
***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

snorkel

  • Hero Member
  • *****
  • Posts: 817
Re: tstream readcomponent issue
« Reply #1 on: July 21, 2016, 09:48:00 pm »
Well, I think I figured it out.
It has to do with the visual component  fields in the param editor which are limited to 255 chars.
If I set the param value  to say 'test' then send it across the wire, read the component from the stream and then
 do in code on the newly spawned component:  q1.params.parambyname('keytext').asstring:= 'some really big text.....' 
works no problem and the component can then be executed.

Is there anyway around this other than sending the larger param value separately?

***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: tstream readcomponent issue
« Reply #2 on: July 22, 2016, 09:29:41 am »
As far as I know ObjectTextToBinary and ObjectBinaryToText supports streaming the full content of a memo. Try to use that.. If it works you should also be able to stream the binary data direcdtly over a tcp/ip stream since these functions take Tstream parameters. The Delphi documentation is rather better than that of Lazarus concerning these and contain a nice on-line example that should get you going.

Note you can better use Tmemo.lines.text. That is normally a long string. Unless all your code is in mode {$H-} or {$LONGSTRINGS OFF} that is.
« Last Edit: July 22, 2016, 10:09:33 am by Thaddy »
Specialize a type, not a var.

snorkel

  • Hero Member
  • *****
  • Posts: 817
Re: tstream readcomponent issue
« Reply #3 on: July 22, 2016, 05:28:41 pm »
Thaddy,
What I ended up doing is just using the format command to put the large text right in the SQL statement, which does not have the 255 char limit in the IDE property editor.
I did build my code from the delphi examples using the stringToComponent function.

object zquery: TZSQLProcessor
  Params = < 
    item
      DataType = ftString
      Name = 'tablename'
      ParamType = ptUnknown
      Value = 'ssh_keys'                   <---------------  Error is raised when value field of params is greater than 255
    end 

I will have to research and see if it's a Lazarus limitation or if the Zeos component could be modified to have the value field be a different type, I guess it must be defined as a record with a short string for the GUI component editor?

It seems to take any size value after the component is created via setting it in code rather than the IDE property editor.



***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: tstream readcomponent issue
« Reply #4 on: July 22, 2016, 06:58:30 pm »
Did you also follow up om Memo.Lines.text?
Specialize a type, not a var.

 

TinyPortal © 2005-2018