1285580 - How to add a Database Table using the Crystal Reports .NET inproc RAS SDK

SAP Knowledge Base Article - Public

1285580 - How to add a Database Table using the Crystal Reports .NET inproc RAS SDK

Symptom

How to add a Database Table using the Crystal Reports .NET inproc Report Application Server (RAS) SDK

Environment

  • Microsoft Visual Studio 2005
  • C#
  • Crystal Reports XI R2 Service Pack 2 and higher versions

Resolution

<Sample code>


      using CrystalDecisions.ReportAppServer.ClientDoc;
      using CrystalDecisions.ReportAppServer.Controllers;
      using CrystalDecisions.ReportAppServer.DataDefModel;
      using CrystalDecisions.CrystalReports.Engine;

        // CR variables
        ReportDocument m_boReportDocument;
        ISCDReportClientDocument m_boReportClientDocument;  // report client document

        PropertyBag                                                                              m_boLogonInfo;          // logon info
        PropertyBag                                                                              m_boAttributes;           // logon attributes
        ConnectionInfo                                                                          m_boConnectionInfo;   // connection info
        CrystalDecisions.ReportAppServer.DataDefModel.Table m_boTable;                       // table
      
         //*****************************
         // create a report from scratch
         //*****************************
            
         //Create a new ReportDocument
         m_boReportDocument = new ReportDocument();

         // load the RPT file 
         m_boReportDocument.Load("..\\..\\dummy.rpt");

         //Access the ReportClientDocument in the ReportDocument (EROM bridge)
         m_boReportClientDocument = m_boReportDocument.ReportClientDocument;
            
          // create report client document
           m_boReportClientDocument = new ReportClientDocument();

           // new report document
            m_boReportClientDocument.New();
           
          
            // create logon property
            m_boLogonInfo = new PropertyBag();

            /* ODBC
            // create logon attributes
            m_boAttributes = new PropertyBag();
            m_boAttributes["Database DLL"] = "crdb_odbc.dll";
            m_boAttributes["QE_DatabaseType"] = "ODBC (RDO)";
            m_boAttributes["QE_ServerDescription"] = "ODBC - Xtreme Sample Database 11.5";
            m_boAttributes["QE_SQLDB"] = true;
            m_boAttributes["Server Name"] = "Xtreme Sample Database 11.5";
           */

            // DAO
            // create logon attributes
            m_boAttributes = new PropertyBag();
            m_boAttributes["Database DLL"] = "crdb_dao.dll";
            m_boAttributes["QE_DatabaseType"] = "Access";
           // m_boAttributes["QE_ServerDescription"] = "ODBC - Xtreme Sample Database 11.5";
            //m_boAttributes["QE_SQLDB"] = true;
            m_boAttributes["Server Name"] = "C:\\Program Files\\Business Objects\\Common\\3.5\\Samples\\En\\Databases\\xtreme.mdb";
         

            // create connection info
            m_boConnectionInfo = new ConnectionInfo();

            m_boConnectionInfo.Attributes = m_boAttributes;
            m_boConnectionInfo.UserName = "Admin";
            m_boConnectionInfo.Password = "";
            m_boConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindSQL;
          

            // create a table
            m_boTable = new CrystalDecisions.ReportAppServer.DataDefModel.Table();
            m_boTable.ConnectionInfo = m_boConnectionInfo;
            m_boTable.Name = "Customer";
            m_boTable.Alias = "Customer";

            // add a table
            m_boReportClientDocument.DatabaseController.AddTable(m_boTable, null);

Note:
Prior to the release of Crystal Reports XI R2 Service Pack 2, report modification was only possible using the RAS SDK with a RAS server or by using In-Process RAS with the purchase of additional licensing.
Using Crystal Reports XI R2 Service Pack 2 and higher, you can now access the report modification APIs without any additional licensing by using the inprocess-RAS engine through the Crystal Reports .NET SDK.


 

See Also

 

Keywords

RAS, Modification, In-Process, .NET, Create, Add, Remove, Change, Modify, ReportClientDocument, inproc, database , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , How To

Product

Crystal Reports 2008 V0 ; Crystal Reports 2008 V1 ; SAP Crystal Reports XI R2