Page 1 of 1

Invalid type cast in file ZDatasetUtils

Posted: 25.08.2020, 17:37
by renabor
Hi all,

After the last update of zeos (svn rev 6794), my project crashes with message "Invalid type cast"

in line 1734, file ZDatasetUtils

ConSettings := TZAbstractRODataset(THackParam(Param).DataSet).Connection.DbcConnection.GetConSettings;


the code that trigger the error is:

ZROQueryCodiciInterventi.ParamByName('FILTRO').AsString := s;

where s is a String
latest running version of zeos was 6758

thanks in advance for any advice,
renabor

FPC 3.2.1, Lazarus 2.0.10, Linux

Re: Invalid type cast in file ZDatasetUtils

Posted: 26.08.2020, 13:06
by marsupilami
Hello renabor,

thank you for the bug report. I created a bug report on Source Forge for this problem: https://sourceforge.net/p/zeoslib/tickets/440/

Currently I can only suggest to go back to the latest working version. A fix can take some weekes because nearly everybody is on holidays right now. You might want to subscribe to the sourceforge bug report.

Best regards,

Jan

Re: Invalid type cast in file ZDatasetUtils

Posted: 10.09.2020, 06:28
by EgonHugeist
Hello renabor,

that's weird, i can't see something wrong. So i added an assertiation See: https://sourceforge.net/p/zeoslib/code-0/6809/.
If the assertiation is triggered, than the DataSet of the Parameter is not an Descendant of the Zeos-TZAbstractRODataset.

So plz update. Is the assertiation triggered? What's the FieldType of the Parameter?

Re: Invalid type cast in file ZDatasetUtils

Posted: 11.09.2020, 07:25
by renabor
Hello EgonHugeist,
the parameter is defined simply as:

sql:='select distinct codice_novo from oc_cup where codice_novo like (:FILTRO) order by codice_novo';
ZROQueryCodiciInterventi.SQL.Text:=SQL;

I've tried to compile the program with target Windows and it run fine!
Same code compiled with target Linux triggered the error.

Linux is case sensitive so I suppose the problem is related to the name of a unit, which mix of upper-lower case does not match corresponding name in the uses clause, or something similar

Best regards,
renabor

Re: Invalid type cast in file ZDatasetUtils

Posted: 11.09.2020, 13:25
by marsupilami
Hello renabor,
renabor wrote: 11.09.2020, 07:25 I've tried to compile the program with target Windows and it run fine!
Same code compiled with target Linux triggered the error.

Linux is case sensitive so I suppose the problem is related to the name of a unit, which mix of upper-lower case does not match corresponding name in the uses clause, or something similar
Do you get this error during compile time or when you run the program? I wonder about this because we currently compile Zeos on Linux (FPC 3.0.4 / Lazarus 2.0.0 x86_64) on a regular basis as part of our automated tests. And we don't get errors during the compilation.

Also - usually the error message you posted happens at runtime. This is why we need a small sample program that can reproduce the error. Otherwise it will be hard to track down the problem. So:
- Please create a small sample program that reproduces the error.
- Please supply a create scrip that creates the necessary tables and inserts data that is needed for the program to run.
- Please tell us which database you use including version numbers for the client and the server.

Best regards,

Jan

Re: Invalid type cast in file ZDatasetUtils

Posted: 16.09.2020, 18:00
by renabor
Hello marsupilami,
yes, problem occurs at runtime.
As you asked, I created a small program with all the code involved but I can't reproduce the error. The test program run as expected, so I think that somewhere in my code there is something bad.
Perhaps a lack of a parameter, or a parameter that is not needed, I don't know.
For now I've resolved switching back using filter instead of parameter,
thankyou anyway for all,
Best regards
renabor