开发者

Database-field with false as value sent over XSD to Crystal Reports is evaluated as true

The application I work on is using a Crystal Reports to present reports to the user. I am using Visual 2010, but the report was created by a previous employee some years back using Visual2005.

The basic setup is that the client application make a request to the server that uses a xsd that define the data-set it sends back. Generally this work like expected, but I am having some problems with evaluating booleans.

A recent task consider of adding the dataset with a field name TrueWeekday that control if certain numbers should be printed out or not depending on if a date is a regular weekday or have some special local meaning that might affect the sampled data. The data is always used in some formulas so I can not exclude it from the dataset.

My first attempt involved defining the new field as a boolean and in the formula for the report I wrote

if {Header.TrueWeekday} then
     CStr({Detail.Flow})
else
     ""

This had the result that no matter if the value in TrueWeekday was false or true the flow was presented. I debuged the server to verify that the variable indeed got the expected value so the problem happened in the Crystal Reports or in the transfer of data to Crystal Reports.

To solve this particular problem within the timeconstraints of t开发者_如何学JAVAhe task I changed the field to the type string and wrote

if {Header.TrueWeekday} = "false" then
     CStr({Detail.Flow})
else
     ""

This worked like a charm.

My problem here is not urgent since I have a working solution, but I am worried that this problem might create more subtle dataintrigity problems.

What might be the cause of this and how do I solve it?


Header.TrueWeekday is probably being passed as a string so that when you do if {Header.TrueWeekday} its testing a string as a boolean in which case if the string contains anything it evaluates to true and thus causes your problem


Work in a different project made me realize that .Net is probably serializing the boolean as the text string true/false. If then Crystal Reports does sloppy import and only check input != 0 you will get the result that both true and false map to true after the transfer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜