Hi everybody,
we would like to use CrystalReports in a Push methods, meaning that we are using pre-defined reports (that were created using an established database connection) and push the data using XML by overriding this database connection. Unfortunately, this does not work in my case.
Environment:
CR SB_CR_5 with "_ACONNECTION" as database connection.
This database connection has the fields SalesVolume and CalendarMonth which are used in the report.
Now, in VS .NET 2008 I created an own dataset with the one table that has the same name as the database conection in CR and entered the two fields as columns. Then I created a xml file according to the fields.
My coding is:
DataSet ds = new DataSet();
ds.ReadXmlSchema(@"C:\CrystalReportsFeeder\CrystalReportsFeeder\Datasets\DataSet.xsd");
ds.ReadXml(@"C:\CrystalReportsFeeder\CrystalReportsFeeder\XmlData\Products.xml", XmlReadMode.InferSchema);
String reportPath = @"C:\CrystalReportsFeeder\CrystalReportsFeeder\Reports\SB_CR_5.rpt";
CR_Report.Load(reportPath);
foreach (CrystalDecisions.CrystalReports.Engine.Table tab in CR_Report.Database.Tables)
{
if (ds.Tables.Contains(tab.Name)) tab.SetDataSource(ds.Tables[tab.Name]);
}
CR_Report.SetDataSource(ds);
Unfortunately, I do get the error "Failed to open database connection, report SB_CR_5 {4..some_value..6}.rpt".
What am I doing wrong??
Thanks,
Pascal