on 02-28-2017 11:45 AM
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.
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 🙂
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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...
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.