melli111
asked on
Visual Studio reporting expression
I have the following expression in a report in Visual Studio Reporting for the Filter expression of a Group:
=Fields!field1.Value < CInt(2007)
The reason for the CInt() is that the field "field1" is of type Int64 and the Expression sees "2007" as a String value. So I use CInt() to convert the value "2007" into a Integer so the types match. However, when running the report, I receive the error
"An error occurred during local report processing.
An error has occurred during report processing.
The processing of FilterExpression for the table ‘table1’ cannot be performed. Cannot compare data of types System.Int64 and System.String. Please check the data type returned by the FilterExpression."
I am very frustrated by this error. I converted the String type "2007" to an Integer value, yet it is still seeing "2007" as a String value
=Fields!field1.Value < CInt(2007)
The reason for the CInt() is that the field "field1" is of type Int64 and the Expression sees "2007" as a String value. So I use CInt() to convert the value "2007" into a Integer so the types match. However, when running the report, I receive the error
"An error occurred during local report processing.
An error has occurred during report processing.
The processing of FilterExpression for the table ‘table1’ cannot be performed. Cannot compare data of types System.Int64 and System.String. Please check the data type returned by the FilterExpression."
I am very frustrated by this error. I converted the String type "2007" to an Integer value, yet it is still seeing "2007" as a String value
ASKER
Same exact error when I do that. I do not see how the expression on the right side, 2007, is still a string type. Very frustrating. CInt() is teh conversion method I saw when using the Expression Builder.
ASKER
Okay I figured out part of it. The error stems from the fact that the Expression sees anything just as is as a String. For example, "Year" and "2007" are both seen as a string. "=2007" is seen as a NUMBER. So that solves the conversion error. However, the expression is still not filtering out to only everything before 2007. It pulls ALL of the data
ok, so now how your code looks? something like this?
=Fields!field1.Value <= 2007
=Fields!field1.Value <= 2007
ASKER
I have attached a screenshot of the expression I am using. It still does not pull the correct values.
ReportingExpression.jpg
ReportingExpression.jpg
ASKER
My apologies. The previous screen shot was the old one. Here is what I am currently using
correctreportingexpression.jpg
correctreportingexpression.jpg
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try using Int64.Parse Method
=Fields!field1.Value < Int64.Parse(2007)
But are you sure that Field1 data type is Int64?