Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Changing datasource from ODBC into XML file

I try to change the datasoruce of a report from a ODBC databse into a XML file.

I found the thread about ReplaceConnection_Click (see below) but I am afraid that will do not help me.

Our situation: we do have a lot of reports created with a SQL Anywhere 10 database (ODBC). In the reports there are a dozens of tables with each a dozen of columns. These reports are printed by our PowerBuilder RDC program.

Now we like to print these reports with .NET outside our old PowerBuilder program.

Our PowerBuilder can export a XML file containing all the data needed for the report. Alle data is exported in one table "Table", the column names are in the format table_column.

For example; a orderconfirmation XML looks like:

<Table>

<Customers_number>10</Customers_number>

<Orders_number>123</Orders_number>

<Orders_date>01-05-2011</Orders_date>

<Orderlines_description>Coca cola bottle</Orderlines_desription>

</Table>

(the original report contains 3 tables, Customers, Orders and Orderlines)

In .Net wWe import this XML into a dataset. Now we have to replace the datasource and map the fields to the corresponding values of the dataset. For example: if the report uses the field "description" from table "orderlines" it should map to the dataset Table and column "orderlindes_description" .

How do we change the datasource from the ODBC database with a XML datasource and remap the fields ?

Tia

Hans

-


private void ReplaceConnection_Click(object sender, EventArgs e)

{

CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

ISCDReportClientDocument rcd;

rcd = rptClientDoc;

rptClientDoc.DatabaseController.LogonEx("dwcb12003", "xtreme", "sb", "pw");

//Create the logon propertybag for the connection we wish to use

CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag logonDetails = new CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag();

logonDetails.Add("Auto Translate", -1);

logonDetails.Add("Connect Timeout", 15);

logonDetails.Add("Data Source", "dwcb12003");

logonDetails.Add("General Timeout", 0);

logonDetails.Add("Initial Catalog", "Orders");

logonDetails.Add("Integrated Security", "True");

logonDetails.Add("Locale Identifier", 1033);

logonDetails.Add("OLE DB Services", -5);

logonDetails.Add("Provider", "SQLOLEDB");

logonDetails.Add("Use Encryption for Data", 0);

logonDetails.Add("Owner", "dbo"); // schema

//Create the QE (query engine) propertybag with the provider details and logon property bag.

CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag QE_Details = new CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag();

QE_Details.Add("Database DLL", "crdb_ado.dll");

QE_Details.Add("QE_DatabaseName", "Orders");

QE_Details.Add("QE_DatabaseType", "OLE DB (ADO)");

QE_Details.Add("QE_LogonProperties", logonDetails);

QE_Details.Add("QE_ServerDescription", "dwcb12003");

QE_Details.Add("QE_SQLDB", "True");

QE_Details.Add("SSO Enabled", "False");

QE_Details.Add("Owner", "dbo");

CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo newConnInfo = new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo();

CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo oldConnInfo;

CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfos oldConnInfos;

oldConnInfos = rcd.DatabaseController.GetConnectionInfos(null);

for (int I = 0; I < oldConnInfos.Count; I++)

{

oldConnInfo = oldConnInfos;

newConnInfo.Attributes = QE_Details;

newConnInfo.Kind = CrystalDecisions.ReportAppServer.DataDefModel.CrConnectionInfoKindEnum.crConnectionInfoKindCRQE;

rcd.DatabaseController.ReplaceConnection(oldConnInfo, newConnInfo, null, CrystalDecisions.ReportAppServer.DataDefModel.CrDBOptionsEnum.crDBOptionDoNotVerifyDB);

}

}

Thanks

Don

Former Member

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question