Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: XML Data source element doesn't always exist Post Reply Post New Topic
Author Message
mzda
Newbie
Newbie


Joined: 09 Oct 2009
Online Status: Offline
Posts: 5
Quote mzda Replybullet Topic: XML Data source element doesn't always exist
    Posted: 22 Jan 2010 at 3:30am
Hi,
I have a report with an xml file as a data source.
The report is loaded on an aspx website and the xml data is generated on the fly and than passed to the crviewer as a dataset.

In this described case below, the crviewer always say database login failure(German: Datenbankanmeldung fehlgeschlagen)

How to solve this ?

The report is designed for this xml source

<Company>
<Street>Street</Street>

<Person>
<Firstname>X</Firstname>
<Lastname>Y</Lastname>
</Person>

<Person>
<Firstname>A</Firstname>
<Lastname>B</Lastname>
</Person>

</Company>

But there are cases, where the company doesn't have person. For example:
<Company>
<Street>Street</Street>
</Company>


If I try to load this in web, crystal report says "Database login failure"

And if I try to load preview the report in the crystal report designer, it tries first of all to look for the field Company_Id, which is usually automatically generated by crystal report to link the person to the company.

Then it says, that the table Person is not found. and whether I want to remove the table from the report or not. If I say no, it says that the database is refreshed and than not implemented.

What should I do ? Isn't it possible that crystal report automatically knows that if the child table doesn't exist to just skip it ?

Thanks

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 25 Jan 2010 at 6:52am
No, Crystal is pretty dumb, like most reporting programs.  If you say that something is supposed to be there, and reference it in a report, then when it is missing, it complains.
 
Easy way around this, pass a record of no person when there is no one and have Crystal suppress it, then everyone is happy.  Sure it a few more bytes in your xml file, but nothing in the grand scheme of things.
 
HTH
IP IP Logged
mzda
Newbie
Newbie


Joined: 09 Oct 2009
Online Status: Offline
Posts: 5
Quote mzda Replybullet Posted: 08 Feb 2010 at 4:32am
Hi lockwelle,
thanks for your input. The problem is, that the xml is created dynamically.
Is it possible, that I for example display another error message instead ?
The error message is thrown without an exception, so I can't catch it.
Thanks
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 08 Feb 2010 at 6:02am
Well, the simplest solution then is to have your application that creates the xml raise the message that the table is blank.
 
I use xml all the time, I just don't use linked tables. I would have thought that CR would recognize that the table is empty, but...
IP IP Logged
mzda
Newbie
Newbie


Joined: 09 Oct 2009
Online Status: Offline
Posts: 5
Quote mzda Replybullet Posted: 09 Feb 2010 at 1:55am
Hi lockwelle,
thats the point. I also have the same assumption, that CR would recognize this.
And since the table is created dynamically, I can't check which table is blank because its supposed to be there or the table is really should not be in the structure :(
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 09 Feb 2010 at 6:36am
when you designed the report, did you provide a schema? 
 
xml won't write entries that are null, so, it the table is blank, the report won't see it (in the xml) but it has fields that are being used, and when CR doesn't see the fields, it throws an error.
 
 
IP IP Logged
mzda
Newbie
Newbie


Joined: 09 Oct 2009
Online Status: Offline
Posts: 5
Quote mzda Replybullet Posted: 09 Feb 2010 at 7:42am
Hi lockwelle,
the problem is, there is a formula which reference to this table. I think the problem is in the formula, because it doesn't check whether the field/table exists or not. How to do this ?
Thanks
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 10 Feb 2010 at 6:38am
the only fuctions that I know of in CR would be ISNULL.  I don't think that there is a comparison to Nothing.
 
HTH
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.