Quantcast
Channel: SCN : Discussion List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 6412

How to change the connection information of a crystalreport configured against HANA.

$
0
0

Hi,

 

We have a crystalreport in which datasource is connected to HANA ODBC, we have 3 schemas and each contain table named OCPR.

Report is configured agianst OCPR in the 3rd schema, but when the report is executed (using .Net crystalreportviewer and ReportDocument) data is showing from the 1st schema.

 

How can we change the schema and server information through code (.Net).

 

I have tried the below given code from the link http://scn.sap.com/thread/3481487, but its not changing the connection information.

 

CrystalDecisions.CrystalReports.Engine.ReportObjects crReportObjects;

 

    CrystalDecisions.CrystalReports.Engine.SubreportObject crSubreportObject;

 

    CrystalDecisions.CrystalReports.Engine.ReportDocument crSubreportDocument;

 

    CrystalDecisions.CrystalReports.Engine.Database crDatabase;

 

    CrystalDecisions.CrystalReports.Engine.Tables crTables;

 

    TableLogOnInfo crTableLogOnInfo;

 

 

 

    CrystalDecisions.Shared.ConnectionInfo crConnectioninfo = new CrystalDecisions.Shared.ConnectionInfo();

 

         

 

    //set up the database and tables objects to refer to the current report

 

    crDatabase = rpt.Database;

 

    crTables = crDatabase.Tables;

 

    bool mainSecureDB;

 

 

 

    //loop through all the tables and pass in the connection info

 

    foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)

 

    {

 

        mainSecureDB = rpt.Database.Tables[tableIndex].LogOnInfo.ConnectionInfo.IntegratedSecurity;

 

        string mainTableName = crTable.Name.ToString();

 

        tableIndex++;

 

        //pass the necessary parameters to the connectionInfo object

 

        crConnectioninfo.ServerName = "Hana"; // Your DSN

 

        if (!mainSecureDB)

 

        {

 

            crConnectioninfo.UserID = "YourUserName";

 

            crConnectioninfo.Password = "YouPassword";

 

            crConnectioninfo.DatabaseName = "XTREME.CUSTOMER"; // Your DB and table

 

        }

 

        else

 

            crConnectioninfo.IntegratedSecurity = true;

 

 

 

        crTableLogOnInfo = crTable.LogOnInfo;

 

        crTableLogOnInfo.ConnectionInfo = crConnectioninfo;

 

        crTable.ApplyLogOnInfo(crTableLogOnInfo);

 

 

 

Thanks


Viewing all articles
Browse latest Browse all 6412

Trending Articles