You are on page 1of 9
SAP Community > Products and Technology > Technology > Technology Q&A > How to change data povider programmatically using ... Allcommunity » What are you looking for today? Optiong How to change data povider programmatically using .net Y Goto solution former_member468298 Participant © on 06-28-2017 We would like to programmatically change the data provider used by a report. Currently we are using ODBC and we no longer want to depend on the this middleware. Is possible to programmatically change the objects within the report's report document object to use a direct data connection or OLE DB connection? We would rather not change them through Crystal Report's designer if possible due to the number of reports that we would have to change. SAP Managed Tags: SAP Crystal Reports, version for Visual Studio Y Show replies ~ Accepted Solutions (1) ED” former_member11696 Employee © 07-05-2017 0 Kudos CR 2008 runtime is not supported in VS 2010 or above. To get the runtime for CR 2011 and above go here: https://wiki,scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C-+Developer+for+Visual+ Studio+Downloads Update all references to version 13. On the WIKI page there is a demo app for setting log on info and using RAS and ReplaceConnection(); Don Show replies v Answers (4) ED” former_member11696 Employee © 07-21-2017 O Kudos Not sure what you are referring to, please explain? They are all labels or indexes as I see them... Show replies Qo © sormer_membertisse Employee © 07-19-2017 0 Kudos On the download page there is a link for a parameter test app: :/Iblogs.sap.com/2016/02/17/how-to-parameters-in-crystal-reports-f It has a ReplaceConnection button, use it to set the info and the DB connection info is retrieved via the Load() routine: JI get the DB name from the report, CrystalDecisions.CrystalReports.Engine.Database crDatabase; CrystalDecisions.CrystalReports.Engine-Tables crTables; crDatabase = rpt.Database; crTables = crDatabase Tables; int dbx = 0; btnSQLStatement-Text += "\nMain Report Table count: " + rpt.Database.Tables.Count ToString0; foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables) { if (crDatabase.Tables.Count != 0) { CrystalDecisions. Shared.NameValuePair2 nvp2 = (NameValuePair2)rpt.Database.Tables[dbx].LogOninfo.ConnectionInfo.Attributes.Collecti on[1}: btnsQLStatementText rpt.Database.Tables[dbx]. LogOninfo.Connectioninfo.ServerName-ToStringQ) + “\n "\nRPT Data Source Info: \n" +" Server Name: " + Database Name: " + nvp2.Value-ToString() + "\n Table Name: " + rpt.Database-Tables{dbx]. Name-ToString(); if (1pt.Database Tables[dbx].LogOnInfo.Connectioninfo.UseriD != null) btnSQLStatement.Text "\n User ID: + Ipt.Database.Tables[dbx].LogOnInfo.ConnectionInfo.UserID ToString() + "\rin"; dbx++; } else btnSQLStatement-Text += "No Data source or not found\r\n"; } Now search for subreports and get it's connection properties. It's in the private void ReplaceConnection_Clict Don Y Show replies former_member468298 Participant © 06-29-2017 0 Kudos See question about code below Y Show replies Delilsc Active Contributor © 06-29-2017 O Kudos Here's some C# sample code to get you started. You'll probably have to tweak this, though. private void updateLogon(ReportDocument newRpt, string alias) { for (int i = 15 i <= newRpt.Database.Tables.Count; i++) { ConnectionInfo cInfo = newRpt.Database.Tables[i] .LogOnInfo.ConnectionInfo; cInfo.AllowCustomConnection = true; cInfo.ServerName = alias; cInfo.UserID = _rptUser; cInfo.Password = _rptPW; NewRpt Database. Tables[i].Location = _rptPrefix + "." + newRpt.Database. Tab] } ///10D0: finish setting this up //3f necessary, set the database driver if (_updatedriver @& (_dbDriver != DeDrivers.SQL_Server)) { switch (_dbdriver) i case D8Drivers.Oracle: newipt .ReportLogons[j].CustonServerType = CeReportServerType.ceServert break; case DaDrivers.DB2: newRpt .ReportLogons[j].CustonServerType = CeReportServerType. ceServerT break; case DBDrivers..ADO newRpt .ReportLogons[j].CustonServerType = CeReportServerType.ceServerT ‘crdb_ado.d11"; newt .ReportLogons[j].CustomDatabaseDLLName break; case D8Drivers.BTrieve newRpt .ReportLogons[j].CustonServerType = CeReportServerType.ceServerT newRpt .ReportLogons[j].CustonDatabaseDLLName = "crdb_p2bbtrv.d11"; break; case DBDrivers ODBC: newRpt .ReportLogons[j].CustonServerType = CeReportServerType. ceServer? newRpt .ReportLogons[j].CustonDatabaseDLLName = "crdb_odbc.d11"; break; case DBDrivers.OLAP: newRpt .ReportLogons[j].CustonServerType = CeReportServerType. ceServerT newRpt .ReportLogons[j].CustonDatabaseDLLName = "crdb_olap.d11"; break; case DBDrivers.XMl newRpt .ReportLogons[j].CustonServerType = CeReportServerType. ceServerT newRpt .ReportLogons[j].CustonDatabaseDLLName = "crdb_xml.d11"; break; -Dell Y Show replies Ask A Question Type your question here... Recommendations v fA what is net change planning and Planning relevant ... 01-09-2013 v fA Changed Datasource Location programmatically And S... 03-05-2014 v fA Block items in a payment run programmatically. F1... 08-13-2013 v AA How the "PO net price” field can not be changed? 07-17-2012 v fA Data Type change of Characteristics > 06-13-2013 Related Content Consuming OData URL in CPI with GET Method in Technology Blogs by Members Thursday Graph intro series, part 5: Use Graph Securely with Real Data — Authentication in Technology Blogs by SAP 4 weeks ago Changes in AppLocking Authorization Mechani in Technology Blogs by SAP 02-12-2024 Using Generative Al to Migrate Java Mapping to Cloud Integration - Part 1: The Concept in Technology Blogs by SAP 01-31-2024 SAP Kyma deployments easy with ArgoCD multiple-sources apps in Technology Blogs by SAP 01-10-2024 Top Q&A Solution Author Oo SD” SAPSupport v9 9 S07 Edrilan_Berisha v2 D_ Dinu v 10 S _ Sandra_Rossi vi Q woven GP verve D__ Donwittiams View all Latest Posts MDK Dependecys installer JAVA_HOME is different ve... Re: Calculation on the values from a single column... SAP Build Apps / Focus input not working Follow f ¥ @ in Copyright Trademark Support ns of Use Legal Disclosure Newsletter Cookie Preferences

You might also like