SAP Knowledge Base Article - Public

1325291 - How to change HTTP(S) Data Source for XML and Web Services driver at runtime with CR .NET or RAS SDK?


  • .NET Windows or web application.
  • Crystal Report XML and Web Services driver. 
  • How to change the HTTP(S) Data Source at runtime with CR .NET SDK?


  • Crystal Reports 2008
  • Report Application Server (RAS) SDK 
  • XML and Web Services database driver



using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.ReportAppServer.ClientDoc;
public partial class _Default : System.Web.UI.Page 
ReportDocument boReportDocument;
protected void Page_Init(object sender, EventArgs e)
 boReportDocument = new ReportDocument();
 ISCDReportClientDocument boReportClientDocument = null;
 CrystalDecisions.ReportAppServer.DataDefModel.Database boDatabase;
 CrystalDecisions.ReportAppServer.DataDefModel.Tables boTables;
 // Load the report and access the ReportClientDocument for some RC API work
 boReportClientDocument = boReportDocument.ReportClientDocument;
 // Get a handle on the Tables in the report.
 boDatabase = boReportClientDocument.Database;
 boTables = boDatabase.Tables;
 // Make changes to all the Tables in the report so the XML URL is new.
 foreach (CrystalDecisions.ReportAppServer.DataDefModel.Table boTableOld in boTables)
 // Clone the existing table so we have a new table to work with
 CrystalDecisions.ReportAppServer.DataDefModel.ISCRTable boTableNew = boTableOld.Clone(true);
 CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo boConnectionInfo = boTableNew.ConnectionInfo;
 CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag boAttributes, boLogonProperty;
 boAttributes = (CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag)boConnectionInfo.Attributes;
 boLogonProperty = (CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag)boAttributes["QE_LogonProperties"];
 // This should be the only QE_Logon_Property we need to change. The schema should remain static
 boLogonProperty["Http(s) XML URL"] = "http://localhost/cr12_change-location_xml-web-services/Xml/test2.xml";
 // Apply the changes.
 boReportClientDocument.DatabaseController.SetTableLocation(boTableOld, boTableNew);
 CrystalReportViewer1.ReportSource = boReportDocument;
protected void Page_Unload(object sender, EventArgs e)
 boReportDocument = null;


KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , How To


Crystal Reports 2008 V1 ; SAP Crystal Reports, developer version for Microsoft Visual Studio