Skip to Content
0

How to avoid Logon Failure when using ADO.Net XML datasource

Feb 28, 2017 at 11:45 AM

54

avatar image

I have a screen written C# that accepts an XML file and a RPT file. The RPT is linked to an ADO.Net XML datasource and this is changed at runtime using the Location attribute.

It uses the following code (in a loop) to change the location:
voReportDocument.Database.Tables[viTable].Location = P_XMLFile;

Similar code is used to set the table locations on all the sub-reports.

The screen is used to display various documents and reports, the XML schema will be different for each report.

This works, however when something new is added to the the XML then Crystal Runtime refuses to display the report and instead shows a Logon Failure.

This can be worked-around by updating the data source in the report to match the new XML however this means editing dozens of reports each time we add something new to the XML data.

Is there a way to avoid having to manually update the report every time we add to the XML?
Is the a "proper" and "correct" way to do this?

I have tried using VerifyDatabase() but this made no difference.

10 |10000 characters needed characters left characters exceeded

I did succeed in getting this work in an unsupported environment (Progress OpenEdge 11) so I know the Crystal Viewer is capable of reading the XML even when new fields have been added since the report was created - I've seen it do it and have an app that can demonstrate this. Unfortunately I had to abandon the Progress OpenEdge 11 app because it suffered from memory leak problems and there was no support possible from SAP or from Progress.

To solve that problem I built a new, nearly identical, app in Visual Studio in C#. The code is very similar but suffers from the "Logon Failed" messages when reading from the XML if the XML schema has changed in any way since the report was created.

So now I have two apps with near identical code - one with a memory leak and one that gets upset when the XML has changed.

No answers yet - I don't mind paying for a support ticket from SAP if it will solve my problem. Is this something they would be willing to help with?

0
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Derek Harrison Mar 20, 2017 at 01:45 PM
0

Thanks for the links.

Fortunately I am dealing with small amounts of data - typically these are single page forms such as invoices so this solution works for my situation. Trying to keep all the many forms that I have in sync with the XML data would be a great deal of work - I would rather not have to do that :-)

Share
10 |10000 characters needed characters left characters exceeded
Don Williams
Mar 13, 2017 at 03:54 PM
0

Hi Derek,

No, CR Reports assume the data source does not change, it doesn't matter what the source is, if the Table/Field source is updated you need to Verify the report in CR Designer if you want to use it in code.

The reason is the RPT files keeps an image of the data source in it, when that changes the Designer needs to update the info in the RPT file.

You could try ReplaceConnection(), that may work. Search KBA system for an example of how to use the API.

You could also try using the .ADD() methods to add the new table/field info to the report.

Don

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Don,
Thanks for the answer.

Where do I find the KBA system? The only one I can find appears to want a S-User ID and says I have a P-User ID and I'm not sure if it is even this is even the correct site (https://support.sap.com/home.html). It looks like support for SAP One.

The only API documentation I can find is on the MSDN site - is this available somewhere on the SAP site?

Which object would that .ADD() method be on?

The only example I can find for ReplaceConnection() seem to use ConnectionInfo which wants a database name, server, user name and password but I have none of these because it is an XML file.

I will also try reading the XML into a DataSet and using that instead...

0
Don Williams
Mar 15, 2017 at 05:12 PM
0

You can go to help.sap.com or the legacy site:

http://help-legacy.sap.com/bobip

And search for it.

For CR for VS all of the info is here:

https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C+Developer+for+Visual+Studio+Downloads

I suggest fixing the XML and loading the XML into the report, using a Dataset is going to limit the amount of data the report can use.

Don

Share
10 |10000 characters needed characters left characters exceeded
Derek Harrison Mar 14, 2017 at 04:52 PM
0

I think I've beaten it!

I replaced all the code that sets the .Location on all the tables and instead loaded the XML into a DataSet and used that as the data source instead.

So now it does (I've reduced this to just the minimum code for this post):

DataSet  vDataSet;
vDataSet = new DataSet();

voReportDocument.Load(P_ReportFile);

vDataSet.ReadXml(P_XMLFile);
voReportDocument.SetDataSource(vDataSet);

Instead of:

voReportDocument.Load(P_ReportFile);

for (viTable = 0; viTable < voReportDocument.Database.Tables.Count; viTable++) 
{
    voReportDocument.Database.Tables[viTable].Location = P_XMLFile;
}

This doesn't seem to care if the XML is slightly different - I have successfully used 5 years old reports with the latest XML with no errors. Previously these report logon failures, now they just work.

I would still like to know how to get to the Crystal Knowledge Base and where the API documentation is.

Share
10 |10000 characters needed characters left characters exceeded