class EVariantTypeCastError with message 'Could not convert variant of type (String) into type (Double)

前端 未结 3 1303
暖寄归人
暖寄归人 2021-01-20 20:32

Using Delphi and FastReport I get this error message while debugging inside Delphi immediately after this line:

.ShowReport(true)         


        
相关标签:
3条回答
  • 2021-01-20 20:52

    This is just the debugger. It's probably just getting an expected error (one handled by a try..except in the FR code) and properly dealing with it, but the debugger has no way of knowing that and tells you the exception happened. (It's a common issue when working with Indy, which raises exceptions as part of normal program flow.)

    There are three ways to deal with this situation when debugging:

    1. Just hit Continue on the exception dialog when it appears. (You can tell it's a debugger exception because you get the Break or Continue option, and because it only happens when debugging.)

    2. You can disable a specific exception class (or all exceptions) when debugging, using the Tools->Options->Debugger Options. In this case, you can add EVariantTypeCastError to the list of exceptions to ignore.

    3. (My preferred method) Use the Advanced Breakpoint Properties dialog to skip the debugger's exception handling around the specific line of code you know will raise the exception you want to ignore.

      • Set a breakpoint on the line immediately before the problem code line.
      • Right-click the breakpoint on the line before, and choose Breakpoint Properties from the context menu.
      • Click the Advanced button on the Breakpoint Properties dialog, and in the Actions groupbox, uncheck Break and check Ignore subsequent exceptions.
      • Repeat the previous steps on the line after the problem code, except check Break and uncheck Ignore subsequent exceptions on this second breakpoint.
      • Run your code as usual. The debugger will skip it's exception handling on the code between the two breakpoints.

    The advantage of option #3 is that it ignores all exception handling, but only on the code block between the two breakpoints, so you still get exceptions in all other areas of your code that may be valid exceptions in the debugger.

    0 讨论(0)
  • 2021-01-20 21:05

    I had a similar issue in FastReport. In my case, it was a wrong Format applied to a MemoView. I could find the name of the offending component this way:

    • Use Break to stop the execution
    • In the Call Stack panel, find the latest call from a fastreport class (in my case: frxClass.TfrxCustomMemoView.FormatData(...) and double click it.
    • if you don't have the source code od Fast Report, a dialog appears - just hit Cancel
    • in Local Variables panel, you will probably see name of the offending component / value / format.
    0 讨论(0)
  • 2021-01-20 21:15

    I got this exact same error but not with FastReport. I'll leave the context of my error, as it may help someone else. I got this error on:

    RESTRequest.Execute();

    I was using the TClientDataSet with TRESTResponseDataSetAdapter so that after a request to my web service the adapter would load a data set with the JSON string returned by the web service. This data set was being used to automatically check/uncheck checkboxes and load textedits and comboboxes. Since TJSONObject does not parse booleans correctly in json, I changed some checkboxes to check/uncheck based on an integer value instead of a boolean. I was then changing my webservice so that it looks for boolean columns in the datatable to an integer value 1 or 0. For some reason (my fault entirely), I was outputting a json with "" in that field instead of the integer ("1" or "0"). And this yielded that exact error. After correcting this, the error disappeared.

    0 讨论(0)
提交回复
热议问题