views:

964

answers:

3

Afternoon Developers,

I have a problem that's beginning to get on my wick. I have looked through google and Crystal Reports help and am still stuck for a solution.

We have created an XSD complete with full information about data-types and the like. A report has been created that is linked to this XSD (using a c# class generated using Microsoft's xsd.exe SDK) and uses the field information to fill the report.

From c# we are instantiating this report and populating it with an XML file that conforms to this XSD and has been validated against it.

Now the problem is that although everything validates without errors (Crystal formulas etc) and compiles fine, when we run the application and attempt to populate the Crystal Report the Report seems to loose all knowledge of the data-typing.

Formulas such as

if ({LetProperty.lp_buildings_selected} = true) then
    "Standard Cover With Accidental Damage Cover"
else
    "Standard Cover";

come back with "A string is required here." error. This formula should run fine as the field referenced is a Boolean Data-Type, Crystal Reports knows this in design time.

To get it to work we have been needed to cast the field ToText and compare it to 'true'. This is a simple work around but we will be creating many reports and don't want to twist code that should work into 'Fudged' messy code that will work.

Can anybody tell me if I am missing something glaringly obvious or if there is something that we need to set as this is confusing us immensely!

Many Thanks all.

A: 

Is LetProperty.lp_buildings_selected set to anything besides "true" or "false" in the XML document (perhaps empty string)? If so this may be the reason that Crystal Reports is trying to use it as a string.

I believe the generated XSD is probably set up by the prevent that, but thought I'd throw it out there anyway.

Dusty
No it comes through as either True or False. It can't be Null or an empty string. Thanks for your input though.
Louis Russell
+1  A: 

Right,

I just wanted to let anyone know how we solved this if anyone ever gets stuck in the same situation.

What we needed to do was before populating the created dataset from the Xml file (to pass to the Report) we read the Xsd into the Dataset so that it was then strong typed and contained all the Data-typing information also.

I don't know why crystal doesn't keep all the Data-Type information that was assigned to it when we created it and linked it to the Xsd but this is how we got around that.

Louis Russell
+1 I haven't done a ton of reports based on XML so I wasn't aware f this. I'd probably just have done the ToText solution to get around it to save time, but it is good to know about this issue.
Dusty
A: 

Is the problem just that you need to include the schema in each XML file? Doing this will have the full type information sent to Crystal as you tell it the XML file is the DataSource. I think I had a problem like you mentioned when I did not include the XSD in the header of the XML file.

Rob Packwood