cancel
Showing results for 
Search instead for 
Did you mean: 

Report containing subreports created via rcapi, logon data not passed through

Former Member
0 Kudos

Hi all

I've "succeeded" in generating a reportdefinition dynamically (using only C# code, didn't do any creating/defining in the Designer), based on choices made by the user of my application:

"succeeded", because the report definition looks ok - it contains the correct CommandTable definition, the correct subreports are imported.

When i try to view it in the designer, it looks ok, it even produces the wanted results

BUT: When viewing the report, i have to enter manually the password for the mainreport and for each subreport.

When i create a report using the Designer i have to enter it only once, and it seems the credentials are then passed on to the subreports.

This is also true when using an exporting tool like CRExport, that enters the login and password in the mainreport, but not in the subreports:

CRExport works perfectly for Designer-created reports containing subreports, but not for reports that were created by my code which is - of course - the point of the application.

Obviously i'm missing something.

I've used this tool to generate the necessary code, but even when trying this in a simple standalone testapplication, with most of the things hardcoded, i can't seem to get it to work. (I used the tool on a working report, only changed the content of CommandText)

Could someone please tell we what i have to set in the mainreport/subreports to make the logoninformation from the mainreport be passed on to the subreports?

Version: CR 2011

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Hi Michael

First, we need to get the actual number of CR you are using as CR 2011 does not install any SDK. SDK is installed via "SAP Crystal Reports, Developer Version for Visual Studio .NET" (assemblies would be version 13.x) or the BI Platform (assemblies would be version 14.x).

Next, assuming you are using "SAP Crystal Reports, Developer Version for Visual Studio .NET", make sure you have applied Service Pack 12:

Taking a shot in the dark as to the cause; if the datasource for the report and subreport is different, the subreport will prompt - unless provided with a correct log on. The difference could be that the main report is using ODBC, subreport is using OLE DB. So check the subreport logons n the desingner for any differences.

One thing I am not clear on; do you get the subreports prompting in both the CR desinger and at runtime?

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow us on Twitter

Former Member
0 Kudos

Hi Ludek

First of all, thanks for the quick reply.

The versions that are installed are the following:

  • SAP Crystal Reports 2011(v=14.0.2.364RTM)
  • "SAP Crystal Reports, Developer Version for Visual Studio .NET" (with SP12, v=13.0.12.1494)

==> All the RAS assemblies are 13.x

What do you mean with "if the datasource for the main and the subreport are different?"

The application that generates the report definitions sets identically the same connection information in all the subreports and in the main report. All connect to the same database\instance and DB

The login and password parameters that are provided there are correct, since generating the report definition also automatically inserts all returned fields in a basic layout, which means it can connect to the db, execute the query from the command table and sniff out the fieldnames.

There are some things that feel a little weird:

1. if i create the same main and subreport manually with the designer (exactly the same command table, same linking parameter with subreport, same connection definition) it works.

2. I wrote a small test application to see if the connection information that i saved is effectively written to the .rpt file. As it turns out, only part seems to be:

  • the server, instance and db certainly are written
  • the user and password are not (pass is never written i read, which is good), they are both null
  • the value for "QE_SQLDB" remains "False", although i set it to "True" (also tried the boolean value true, didn't work either) using the code that was generated with the tool (linked to in OP)

When creating the same report (and subreport) with the designer, the value for user is "mylogin", and the value for "QE_SQLDB" is "True". So the designer behaves differently (or i need to do something to make the RAS assemblies behave the same as the designer, but i don't know what...)


3. With the "designer-generated" report definitions, the designer asks only once for the credentials when running the report <--> with the RAS-generated report definitions, the designer asks for credentials for the mainreport and for EVERY subreport

thanks in advance for looking into this

former_member183750
Active Contributor
0 Kudos

Hi Michael

re.: What do you mean with "if the datasource for the main and the subreport are different?"

Say the connection for the main report is ODBC, subreport is OLEDB, or main report is ODBC conn1, subreport is ODBC conn2, etc. From your description, this is not the case so that is good.E.g.; if the main rpt and subrpt use the same connection, the subreport essentially piggy backs on the main report connection.

I am not able to explain the differences in behavior, but I do have a couple of suggestions:

1) See if using code that will force the subreport to log on will help. Something like the code described here:

KBA: 1688540 - How to login to subreport using Crystal Report .Net SDK


2) The following KBA has a utility that you can download and it will write out the logon code for you. Compare that to the code you are using, see if this will work:


KBA: 1553921 - Is there a utility that would help in writing database logon code?



Oh. One more thing. If yuo are using MS SQL, please keep the following in mind:



For OLE DB use:

MS SQL 2005 - OLE DB Provider

MS SQL 2008 - SQL Native 10

MS SQL 2012 - SQL Native 11

MS SQL 2013 - SQL Native 11

For ODBC use:

MS SQL 2005 - SQL Native

MS SQL 2008 - SQL Native 10

MS SQL 2012 - SQL Native 11

MS SQL 2013 - SQL Native 11




- Ludek

Former Member
0 Kudos
  1. 1. I already found that KB article, but i was under the impression that it is used when also running the report yourself (before handing it over to the ReportViewer component). Since i have no control over the environment that ultimately will run the report, i can also not force the applyLogOnInfo in that code to be run on the subreports.
  2. I'm already using the tool u link to (see link in OP) to generate the necessary connectioninfo code.
  3. SQL Server is 2008R2SP1. ==> i should use "SQL Native 10" but i don't have that. Only "SQL Native 11" or "OLE DB Provider" are listed (in the designer). I should mention that on my pc SQL Mgmt Studio 2012 (=v11.x) is installed, that is probably why only version 11 shows up.

UPDATE: for now i am able to generate reports with CrExport where the connection credentials seem to be pushed through to the subreports. However, the reporting webapplication where the reports will also be placed doesn't seem to be able to do it correctly. I've noticed that it still uses version 13.0.4 of the RAS assemblies...

I don't know how i got this far, but it seems to be a combination of

* redefining the default report that i always start from to have a dummy commandtable (CommandText = "Select 1")in it with a connection to the right server.

* NOT trying to overwrite the connectioninfo on the tables, although even in this case, it's weird that the value of QE_SQLDB is being set to false and the user is set to null when saving a copy of the document using SaveAs)

* switching between SQLOLEDB and SQLNCLI11 didn't make any difference....

For good measure, the general overview of what i do now (for each (sub)report) is...

------START SNIP------


//CR Declarations

          CrystalDecisions.CrystalReports.Engine.ReportDocument document;

          ISCDReportClientDocument m_boReportClientDocument;

          //Create a new ReportDocument

          document = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

          //Access the ReportClientDocument in the ReportDocument (EROM bridge)

          m_boReportClientDocument = document.ReportClientDocument;

          //create new report document

          String templateBaseFolder = config.algemeneInstellingen[Constants.REPORTS_TEMPLATES].getWaardeString();

          String templateReportKey = landscape ? Constants.TEMPLATE_LANDSCAPE : Constants.TEMPLATE_PORTRAIT;

          m_boReportClientDocument.Open(templateBaseFolder + "\\"+config.algemeneInstellingen[templateReportKey].toString());

          //get the existing command table and Clone it

          l_boTable = boTables[0].Clone(true) as CommandTable;

          //add parameters

          ...

          //set command text

          ...

          //set password and replace table in the table list

          l_boTable.ConnectionInfo.Password = getPassword();

          boTables[0] = l_boTable;

        

          //replace table location as seen in official examples

          document.ReportClientDocument.DatabaseController.SetTableLocation(boTables[0], l_boTable);

          

          //check if connection to database works correctly

          document.VerifyDatabase();

          //add result fields to details section

          addFields();

          document.ReportClientDocument.SaveAs(reportNaam,config.algemeneInstellingen[Constants.REPORTS_BASEFOLDER].toString());

          document.ReportClientDocument.Close();

-------END SNIP------

Each subreport is saved, closed and added to the main report before the main report is saved and closed.

The subreports are each put in their own details section, and linking is setup accordingly. All of this works correctly.



any suggestions as to how i might be able to get the other software to work? My only angle here now is the difference in assembly versions between the "reporting server" (13.0.4.x) and my pc (13.0.12.x)... but i'm reluctant to have one of the sysadmins upgrade the version, since i don't know if this might break something?



Answers (0)