Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal XI without BO

Status
Not open for further replies.

cardi

Programmer
May 30, 2007
29
CA
Hi,

I have a strange question....

I want to generate Crystal Reports (XI), and I want to use only the Crystal part on the BO server, but the rpt file is not on BO. I'm using Vs2005 with c#.

The reports are non-embedded. I have the following code:

sessionMgr = new CrystalDecisions.Enterprise.SessionMgr();
rpt_Report.EnterpriseSession = sessionMgr.Logon(BOE_User, BOE_Pwd, BOE_Server, secEnterprise);
rpt_Report.Load(Server.MapPath("Reports/" + sReportName));


I don't know if it's good?? I don't want to store my rpt files directly in BO because it's too slow for our clients.

Thanks !
 
If you're working in C# and your reports are not in BO, you do NOT have to connect to BO to run the reports - you can run them directly in your application. Instead of setting the EnterpriseSession, you'll need to set the logon information for the tables. The code looks something like this:
Code:
    CrystalDecisions.Shared.ConnectionInfo connectionInfo = new CrystalDecisions.Shared.ConnectionInfo();

    connectionInfo.ServerName = dbServer;
    connectionInfo.UserID = dbUserID
    connectionInfo.Password = dbPassword;

    // set report connection for main report
    SetDBLogonForReport(connectionInfo, crReport, qServer);
    // set report connection for any subreports
    SetDBLogonForSubreports(connectionInfo, crReport, qServer);

  private void SetDBLogonForReport( 
     CrystalDecisions.Shared.ConnectionInfo connectionInfo, 
     ReportDocument reportDocument, 
     string qServer)
  {
    Tables tables = reportDocument.Database.Tables;
      foreach (Table table in tables)
      {
        TableLogOnInfo tableLogonInfo = table.LogOnInfo;
        tableLogonInfo.ConnectionInfo = connectionInfo;
        table.ApplyLogOnInfo(tableLogonInfo);
      }
  }

  private void SetDBLogonForSubreports(
    CrystalDecisions.Shared.ConnectionInfo connectionInfo,
    ReportDocument reportDocument, 
    string qServer)
  {
    Sections sections = reportDocument.ReportDefinition.Sections;
    foreach (Section section in sections)
    {
      ReportObjects reportObjects = section.ReportObjects;
      
      foreach (ReportObject reportObject in reportObjects)
      {
        if (reportObject.Kind == ReportObjectKind.SubreportObject)
        {
          SubreportObject subreportObject = (SubreportObject)reportObject;
          ReportDocument subReportDocument = subreportObject.OpenSubreport(subreportObject.SubreportName);
          SetDBLogonForReport(connectionInfo, subReportDocument, qServer);
          
        }
      }
    }
 }
You have to have database login information instead of BO login information.

-Dell

A computer only does what you actually told it to do - not what you thought you told it to do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top