cancel
Showing results for 
Search instead for 
Did you mean: 

Table Location Error Oracle and SqlServer

Former Member
0 Kudos

<p>

I would like to use the <b>same report for several data base providers</b> (ODBC, OLEDB SqlServer and OLEDB Oracle).<br />

My original report is designed with ODBC by another department. When I try to change the data base provider to Oracle or SqlServer I have an error at line:<br />

<br /></p>

<code>

&nbsp;//this line throw an exception if the report was not designed with the

same database provider.<br />

switch (provider)<br />

{<br />

&nbsp;&nbsp;&nbsp; case Provider.SqlServer:<br />

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; crTable.Location =

String.Format(&quot;{0}.dbo.&quot;, crConnectionInfo.DatabaseName, crTable.Name); //database.dbo.tablename<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br /> &nbsp;&nbsp;&nbsp; case Provider.Oracle:<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; crTable.Location = String.Format(&quot;.&quot;, crConnectionInfo.DatabaseName, crTable.Name);

//schema.tablename<br />

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br />

&nbsp;&nbsp;&nbsp; default:<br />

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br />

}</code>

<p>Even setting the same location, like this crTable.Location = crTable.Location; the code throws an exception.

I have to change the report schema location at runtime because we have several databases (SqlServer) or schemas (Oracle) and we have to use the same report.

I use Crystal Reports Version=12.0.2000.0</p>

<br />

Here is my complete code:<br />

<code>

private CrystalDecisions.Shared.ConnectionInfo FixDatabaseSqlServer()<br />

{<br />

CrystalDecisions.Shared.DbConnectionAttributes dbAttributes = new

DbConnectionAttributes();<br />

dbAttributes.Collection.Set(&quot;Server&quot;, this.ServerName.Text);<br />

dbAttributes.Collection.Set(&quot;Trusted_Connection&quot;, &quot;false&quot;);<br />

dbAttributes.Collection.Set(&quot;Data Source&quot;, this.ServerName.Text);<br />

dbAttributes.Collection.Set(&quot;Initial Catalog&quot;, this.DatabaseName.Text);<br />

dbAttributes.Collection.Set(&quot;Integrated Security&quot;, &quot;false&quot;);<br />

dbAttributes.Collection.Set(&quot;Provider&quot;, &quot;SQLOLEDB&quot;);<br />

<br />

//setup the connection <br />

CrystalDecisions.Shared.ConnectionInfo crConnectionInfo = new ConnectionInfo();<br />

crConnectionInfo.DatabaseName = this.DatabaseName.Text;<br />

crConnectionInfo.ServerName = this.ServerName.Text;<br />

crConnectionInfo.UserID = this.UserID.Text;<br />

crConnectionInfo.Password = this.Password.Text;<br />

crConnectionInfo.IntegratedSecurity = false;<br />

crConnectionInfo.Attributes.Collection.Set(&quot;Database DLL&quot;, &quot;crdb_ado.dll&quot;);<br />

crConnectionInfo.Attributes.Collection.Set(&quot;QE_DatabaseName&quot;,

this.DatabaseName.Text);<br />

crConnectionInfo.Attributes.Collection.Set(&quot;QE_DatabaseType&quot;, &quot;OLE DB (ADO)&quot;);<br />

crConnectionInfo.Attributes.Collection.Set(&quot;QE_LogonProperties&quot;, dbAttributes);<br />

crConnectionInfo.Attributes.Collection.Set(&quot;QE_ServerDescription&quot;,

this.ServerName.Text);<br />

crConnectionInfo.Attributes.Collection.Set(&quot;QE_SQLDB&quot;, &quot;True&quot;);<br />

crConnectionInfo.Attributes.Collection.Set(&quot;SSO Enabled&quot;, &quot;False&quot;);<br />

crConnectionInfo.Type = CrystalDecisions.Shared.ConnectionInfoType.CRQE;<br />

crConnectionInfo.LogonProperties = dbAttributes.Collection;<br />

<br />

return (crConnectionInfo);<br />

}<br />

<br />

private CrystalDecisions.Shared.ConnectionInfo FixDatabaseOracle()<br />

{<br />

CrystalDecisions.Shared.DbConnectionAttributes dbAttributes = new

DbConnectionAttributes();<br />

dbAttributes.Collection.Set(&quot;Server&quot;, this.ServerName.Text);<br />

dbAttributes.Collection.Set(&quot;Trusted_Connection&quot;, &quot;False&quot;);<br />

dbAttributes.Collection.Set(&quot;Data Source&quot;, this.ServerName.Text);<br />

dbAttributes.Collection.Set(&quot;Provider&quot;, &quot;MSDAORA&quot;);<br />

<br />

//setup the connection <br />

CrystalDecisions.Shared.ConnectionInfo crConnectionInfo = new ConnectionInfo();<br />

crConnectionInfo.DatabaseName = &quot;&quot;;<br />

crConnectionInfo.ServerName = this.ServerName.Text;<br />

crConnectionInfo.UserID = this.UserID.Text;<br />

crConnectionInfo.Password = this.Password.Text;<br />

crConnectionInfo.IntegratedSecurity = false;<br />

crConnectionInfo.Attributes.Collection.Set(&quot;Database DLL&quot;, &quot;crdb_oracle.dll&quot;);<br />

crConnectionInfo.Attributes.Collection.Set(&quot;QE_DatabaseName&quot;, &quot;&quot;);<br />

crConnectionInfo.Attributes.Collection.Set(&quot;QE_DatabaseType&quot;, &quot;OLE DB (ADO)&quot;);<br />

crConnectionInfo.Attributes.Collection.Set(&quot;QE_LogonProperties&quot;, dbAttributes);<br />

crConnectionInfo.Attributes.Collection.Set(&quot;QE_ServerDescription&quot;,

this.ServerName.Text);<br />

crConnectionInfo.Attributes.Collection.Set(&quot;QE_SQLDB&quot;, &quot;True&quot;);<br />

crConnectionInfo.Attributes.Collection.Set(&quot;SSO Enabled&quot;, &quot;False&quot;);<br />

crConnectionInfo.Type = CrystalDecisions.Shared.ConnectionInfoType.CRQE;<br />

crConnectionInfo.LogonProperties = dbAttributes.Collection;<br />

<br />

return (crConnectionInfo);<br />

}<br />

<br />

private void FixDatabase(ReportDocument report, Provider provider)<br />

{<br />

bool setLocationError = false;<br />

string tableLocationPattern = String.Empty;<br />

CrystalDecisions.Shared.ConnectionInfo crConnectionInfo = null;<br />

<br />

switch (provider)<br />

{<br />

case Provider.SqlServer:<br />

crConnectionInfo = FixDatabaseSqlServer();<br />

tableLocationPattern = String.Format(&quot;{0}..&quot;, crConnectionInfo.DatabaseName, &quot;&quot;);<br /> break;<br /> case Provider.Oracle:<br /> crConnectionInfo = FixDatabaseOracle();<br /> tableLocationPattern = String.Format(&quot;.&quot;, crConnectionInfo.UserID, &quot;&quot;);<br /> break;<br /> <br /> case Provider.Undefinded:<br /> default:<br /> break;<br /> }<br /> <br /> //set database login information for the entire report object<br /> report.SetDatabaseLogon(crConnectionInfo.UserID, crConnectionInfo.Password, crConnectionInfo.ServerName, crConnectionInfo.DatabaseName);<br /> <br /> <br /> CrystalDecisions.CrystalReports.Engine.Database crDatabase = report.Database; //Set the CrDatabase Object to the Report's Database <br /> CrystalDecisions.CrystalReports.Engine.Tables crTables = crDatabase.Tables; //Set the CrTables object to the Tables collection of the Report's dDtabase<br /> <br /> foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)<br /> {<br /> TableLogOnInfo crTableLogOnInfo = null;<br /> crTableLogOnInfo = crTable.LogOnInfo;<br /> if (crTableLogOnInfo != null)<br /> {<br /> crTableLogOnInfo.ConnectionInfo = crConnectionInfo;<br /> crTable.ApplyLogOnInfo(crTableLogOnInfo);<br /> <br /> //<br /> //Set location.<br /> //<br /> try<br /> {<br /> //this line throw an exception if the report was not designed with the same database provider.<br /> switch (provider)<br /> {<br /> case Provider.SqlServer:<br /> crTable.Location = String.Format(&quot;.dbo.&quot;, crConnectionInfo.DatabaseName, crTable.Name); //database.dbo.tablename<br /> break;<br /> case Provider.Oracle:<br /> crTable.Location = String.Format(&quot;.&quot;, crConnectionInfo.DatabaseName,

crTable.Name); //schema.tablename<br />

break;<br />

default:<br />

break;<br />

}<br />

crTable.Location = crTable.Location;<br />

<br />

}<br />

catch (Exception ex)<br />

{<br />

setLocationError = true;<br />

//throw;<br />

}<br />

crTable.TestConnectivity();<br />

}<br />

}<br />

<br />

//call this method recursively for each subreport<br />

foreach (ReportObject reportObject in report.ReportDefinition.ReportObjects)<br />

{<br />

if (reportObject.Kind == ReportObjectKind.SubreportObject)<br />

{<br />

FixDatabase(report.OpenSubreport(((SubreportObject)reportObject).SubreportName),

provider);<br />

}<br />

}<br />

}

</code>

<p>

I tried everything I found at forums with no success.<br />

Please, Is there anyone with the same problem who had solved it?

Is it possible to have the same report and several database providers?

<br />

What have do I have to do?

Thank you very much.</p>

Edited by: jporcar on Feb 9, 2010 9:41 AM

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

I'd simplify things significantly.

1) do not use any subreports

2) create a report on MS SQL, make sure the code you use connects there

3) create a report off of Oracle, make sure the code you use connects there

4) the reports above should be one table, one field

5) the reports should be using the same type of connectivity (ODBC, or OLEDB)

6) reports using ODBC can not be made to go to an OLEDB datasource with the CR APIs for .NET. to change from ODBC to OLEDB and vice versa, you'd need to use inprocRas

7) once you have both of the reports working, try to switch them - first in the designer, then at runtime (e.g.; if these can not be changed in the designer, runtime will do the same)

Your Oracle connectivity code would look something like this:

Dim connection As ConnectionInfo 
connection = New ConnectionInfo() 
With connection 
.ServerName = Our Server Name Here 
.UserID = Our User ID Here 
.Password = Our Password Here 
.DatabaseName = Our Database Name Here 
.Type = ConnectionInfoType.SQL 
End With 

Dim CRTableLogOnInfo As TableLogOnInfo 
For Each Tbl As Table In Report.Database.Tables 
CRTableLogOnInfo =Tbl.LogOnInfo 
CRTableLogOnInfo.ConnectionInfo = connection 
Tbl.ApplyLogOnInfo(CRTableLogOnInfo) 
Tbl.Location = Our Schema Here & "." & Tbl.Location 
Next

Note that this is different than MS SQL... Also, note that Oracle is case sensitive.

Ludek

Former Member
0 Kudos

I have done all you tell me above, but I have the same problem. If the report
data source location at design time have the same data base provider that the
data source location at run time everything works. But if the data source
location at design time is different than at runtime, the code you supplied to
me doesn't work.

I'm sure that if you try to program the same sample you have supplied to me you
will have the same unsuccessful result.

I have found too many questions about that problem at Crystal Reports forums
with no real solution.

Please could you tell me whether or not is it possible to change an OleDb
connection at run time from Oracle to SqlServer and reverse? And how to do it...



Here is my C# code that doesn't work at all:





protected void Page_Load(object sender, EventArgs e)
{
//the report data source location at design time is OleDb SQL Server.
ReportDocument doc = new ReportDocument();
string reportFileName = Server.MapPath("CrystalReport1.rpt");
doc.Load(reportFileName);

//I'm trying to change my connction from OleDb SqlServer to OleDb Oracle.
//Oracle Connection info.
ConnectionInfo connection = new ConnectionInfo();
connection.ServerName = "myServerName";
connection.UserID = "myUser";
connection.Password = "myPassword";
connection.DatabaseName = "";
connection.Type = ConnectionInfoType.SQL;

TableLogOnInfo CRTableLogOnInfo = new TableLogOnInfo();
foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in doc.Database.Tables)
{
CRTableLogOnInfo = crTable.LogOnInfo;
CRTableLogOnInfo.ConnectionInfo = connection;
crTable.ApplyLogOnInfo(CRTableLogOnInfo);

//this line throws an exception
crTable.Location = "mySchema." + crTable.Location;

}

CrystalReportViewer1.ReportSource = doc;
CrystalReportViewer1.RefreshReport();
}








Here is my web.config





assembly="CrystalDecisions.CrystalReports.Engine, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
assembly="CrystalDecisions.ReportSource, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
assembly="CrystalDecisions.Shared, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
assembly="CrystalDecisions.Web, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=12.0.1100.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
assembly="CrystalDecisions.Enterprise.Framework, Version=12.0.1100.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
assembly="CrystalDecisions.Enterprise.InfoStore, Version=12.0.1100.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"




Here is the exception.



Server Error in &#39;/CrystalReportsWebSite3&#39; Application.

+No se pudo abrir la conexión.<br />

Detalles:  [Código del proveedor de base de datos: 17 ]No se pudo abrir la

conexión.

CrystalReport1 {9F75D9DA-C524-48AF-9183-50F1E8989DD3}.rpt

Detalles:  [Código del proveedor de base de datos: 17 ]+


Description:

An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.



Exception Details: System.Runtime.InteropServices.COMException: No se
pudo abrir la conexión.

Detalles:  [Código del proveedor de base de datos: 17 ]No se pudo abrir la
conexión.

CrystalReport1 {9F75D9DA-C524-48AF-9183-50F1E8989DD3}.rpt

Detalles:  [Código del proveedor de base de datos: 17 ]



Source Error:








Line 46:
Line 47: //this line throws an exception
Line 48: crTable.Location = mySchema + crTable.Location;
Line 49:
Line 50: }







Stack Trace:






[COMException (0x800002f4): No se pudo abrir la conexión.

Detalles:

No se pudo abrir la conexión.

CrystalReport1 {9F75D9DA-C524-48AF-9183-50F1E8989DD3}.rpt

Detalles: ]

CrystalDecisions.ReportAppServer.Controllers.DatabaseControllerClass.SetTableLocation(ISCRTable CurTable, ISCRTable NewTable) +0

CrystalDecisions.CrystalReports.Engine.Table.set_Location(String value) +842

Default.PageLoad(Object sender, EventArgs e) in d:Usersjosep.porcarDocumentsVisual Studio 2008CrystalReportsWebSite3Default.aspx.cs:48

System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14

System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35

System.Web.UI.Control.OnLoad(EventArgs e) +99

System.Web.UI.Control.LoadRecursive() +50

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627








Version Information:

 Microsoft
.NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4016<!--

: No se pudo abrir la conexión.

Detalles:

No se pudo abrir la conexión.

CrystalReport1 {9F75D9DA-C524-48AF-9183-50F1E8989DD3}.rpt

Detalles:

at CrystalDecisions.ReportAppServer.Controllers.DatabaseControllerClass.SetTableLocation(ISCRTable CurTable, ISCRTable NewTable)

at CrystalDecisions.CrystalReports.Engine.Table.set_Location(String value)

at Default.PageLoad(Object sender, EventArgs e) in d:Usersjosep.porcarDocumentsVisual Studio 2008CrystalReportsWebSite3Default.aspx.cs:line 48

at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)

at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)

at System.Web.UI.Control.OnLoad(EventArgs e)

at System.Web.UI.Control.LoadRecursive()

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

: Exception of type 'System.Web.HttpUnhandledException' was thrown.

at System.Web.UI.Page.HandleError(Exception e)

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

at System.Web.UI.Page.ProcessRequest()

at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)

at System.Web.UI.Page.ProcessRequest(HttpContext context)

at ASP.default_aspx.ProcessRequest(HttpContext context) in c:WindowsMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Filescrystalreportswebsite318edbb7f2522fba9App_Web_6lji7ebm.0.cs:line 0

at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()

at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

-->


 




Thank you very much.

former_member183750
Active Contributor
0 Kudos

I'm going to upload a little utility on our ftp server for you. What you will need to do is open the report in that utility. It will present the code needed - VB and C#. The code uses inProc RAS, but that should not be an issue.

You probably want to read up a bit on inProc RAS. See [this|http://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/10b840c0-623f-2b10-03b5-9d1913866b32] article.

Once the file is on the ftp, you'll get an automatic notification.

Ludek

Former Member
0 Kudos

Thank you very much.<br />

The utility you provided me to generate my code works fine and is very useful.

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi,

I am not able to dowload utility from given location. it says that link is expired.

Could you please reupload that utility.

Thanks,

Vikas

Edited by: vikasJaigude on Nov 18, 2010 10:20 AM

former_member183750
Active Contributor
0 Kudos

What version of .NET? What version of CR?

BTW.; if you could create a new thread and reference the answered thread (such as this one) that would be great.

Ludek

Follow us on Twitter http://twitter.com/SAPCRNetSup

Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

Former Member
0 Kudos

I would also like to download it:

I'm using .Net 3,5 (VS2008) and CR 2008 SP2

Thanks

former_member183750
Active Contributor
0 Kudos

The file has been posted to:

https://sapmats-us.sap-ag.de/download/download.cgi?id=T6G1ENGC03BKRZRR9GGFELMMNOAHN06FBRP6NA5672SIOH...

Please give the server about 1/2 hour to finish the post.

I will see if I can get a permanent place for these files as nobody should need to go around asking like this. Apologies for that.

Happy coding,

Ludek

Former Member
0 Kudos

Ludek,

Would it be possible to get another link set-up for that utility, we are using VS2010 and .Net API's.

(.Net framework 4)

Thank you

Edited by: Jason-CATI on Dec 20, 2010 5:18 PM

Former Member
0 Kudos

I'm very interested in this app. I have a lot of problems/errors with one of my reports and i was unable to print the report on my project

Could you re-upload somewhere? Many thx for advanced

former_member183750
Active Contributor
0 Kudos

Yup. I created a KBase; [1553921 - Is there a utility that would help in writing database logon code?|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_bi/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333533353333333933323331%7D.do] that has the utility attached.

Apologies to all those that had to ask and hunt all everywhere (I should have created the KB in the 1st place).

Happy coding,

- Ludek

Edited by: Ludek Uher on Feb 16, 2011 6:58 AM

Former Member
0 Kudos

Hi,

Could you publish this application for VS2003 and CR 2008 SP2, please?

I'm having the same problem you described trying to connect a MS-SQL Server 2005 DB.

Thanks,

Luis

Former Member
0 Kudos

Hello,

the link above doesn't seem to work anymore. Could you provide an updated link?

Also, would be very useful to for us to be able to do something similar for JRC.

Thanks!

Former Member
0 Kudos

Any chance we could get that utility re-uploaded? It sounds pretty useful!

Thanks!

former_member183750
Active Contributor
0 Kudos

Yup. What version of .NET and CR are you using?

Ludek

Former Member
0 Kudos

Unfortunately, this utility:

There is a utility on our ftp server that will give you the logon code you'd need for your reports. All you have to do is open the reprot with the utility and you will get VB and C# code. The utility is here:

https://sapmats-us.sap-ag.de/download/download.cgi?id=I8XEAX64QU762S0XC8J71OWPTWWJUQKHGZMNZMJSEFV7FJ...

is not available?

former_member183750
Active Contributor
0 Kudos

It only stays on the server for a few days. I'll repost it. You'll get an email from the ftp server once it is back up there.

Ludek

Former Member
0 Kudos

Thank you - all the help is much appreciated - especially to know that when (thinking positively) I DO get it working, we'll still be able to distribute it to our customers!

Former Member
0 Kudos

<p>

We have several unresolved difficultties with Oracle using the code below supplied by SAP.<br />

But I hope it helps.

</p>

<p>

<strong>Access</strong><br />

<code>

//Add these required Crystal Assemblies to your project<br />

//CrystalDecisions.ReportAppServer.DataDefModel<br />

//CrystalDecisions.ReportAppServer.ClientDoc<br />

//CrystalDecisions.ReportAppServer.Controllers<br />

//CrystalDecisions.CrystalReports.Engine<br />

//CrystalDecisions.Shared<br />

<br />

//Add these Crystal Assemblies to the top of your code page<br />

using CrystalDecisions.ReportAppServer.DataDefModel;<br />

using CrystalDecisions.CrystalReports.Engine;<br />

using CrystalDecisions.Shared;<br />

<br />

private ReportDocument ChangeConnectionInfo()<br />

{<br />

ReportDocument boReportDocument = new ReportDocument();<br />

//*EDIT* Change the path and report name to the report you want to change.<br />

boReportDocument.Load(@&quot;c:\reports\yourreport.rpt&quot;,

OpenReportMethod.OpenReportByTempCopy);<br />

<br />

//Create a new Database Table to replace the reports current table.<br />

CrystalDecisions.ReportAppServer.DataDefModel.Table boTable = <br />

new CrystalDecisions.ReportAppServer.DataDefModel.Table();<br />

<br />

//boMainPropertyBag: These hold the attributes of the tables ConnectionInfo

object<br />

PropertyBag boMainPropertyBag = new PropertyBag();<br />

//boInnerPropertyBag: These hold the attributes for the QE_LogonProperties<br />

//In the main property bag (boMainPropertyBag)<br />

PropertyBag boInnerPropertyBag = new PropertyBag();<br />

<br />

//Set the attributes for the boInnerPropertyBag<br />

boInnerPropertyBag.Add(&quot;Data Source&quot;,

@&quot;your_data_base.accdb&quot;);<br />

boInnerPropertyBag.Add(&quot;Locale Identifier&quot;, &quot;1033&quot;);<br />

boInnerPropertyBag.Add(&quot;Office Database Type&quot;, &quot;Access&quot;);<br />

boInnerPropertyBag.Add(&quot;OLE DB Services&quot;, &quot;-6&quot;);<br />

boInnerPropertyBag.Add(&quot;Provider&quot;, &quot;Microsoft.ACE.OLEDB.12.0&quot;);<br />

boInnerPropertyBag.Add(&quot;Use DSN Default Properties&quot;, &quot;False&quot;);<br />

<br />

//Set the attributes for the boMainPropertyBag<br />

boMainPropertyBag.Add(&quot;Database DLL&quot;, &quot;crdb_ado.dll&quot;);<br />

boMainPropertyBag.Add(&quot;QE_DatabaseName&quot;, &quot;&quot;);<br />

boMainPropertyBag.Add(&quot;QE_DatabaseType&quot;, &quot;OLE DB (ADO)&quot;);<br />

//Add the QE_LogonProperties we set in the boInnerPropertyBag Object<br />

boMainPropertyBag.Add(&quot;QE_LogonProperties&quot;, boInnerPropertyBag);<br />

boMainPropertyBag.Add(&quot;QE_ServerDescription&quot;,

@&quot;
Xaloc\epsilonnet\Dietario\Datos\DatosConfig.accdb&quot;);<br />

boMainPropertyBag.Add(&quot;QE_SQLDB&quot;, &quot;True&quot;);<br />

boMainPropertyBag.Add(&quot;SSO Enabled&quot;, &quot;False&quot;);<br />

<br />

//Create a new ConnectionInfo object<br />

CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo boConnectionInfo =

<br />

new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo();<br />

//Pass the database properties to a connection info object<br />

boConnectionInfo.Attributes = boMainPropertyBag;<br />

//Set the connection kind<br />

boConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE;<br />

//*EDIT* Set the User Name and Password if required.<br />

boConnectionInfo.UserName = &quot;UserName&quot;;<br />

boConnectionInfo.Password = &quot;Password&quot;;<br />

//Pass the connection information to the table<br />

boTable.ConnectionInfo = boConnectionInfo;<br />

<br />

//Get the Database Tables Collection for your report<br />

CrystalDecisions.ReportAppServer.DataDefModel.Tables boTables;<br />

boTables =

boReportDocument.ReportClientDocument.DatabaseController.Database.Tables;<br />

<br />

//For each table in the report:<br />

// - Set the Table Name properties.<br />

// - Set the table location in the report to use the new modified table<br />

boTable.Name = &quot;TABLE1&quot;;<br />

boTable.QualifiedName = &quot;TABLE1&quot;;<br />

boTable.Alias = &quot;TABLE1&quot;;<br />

<br />

boReportDocument.ReportClientDocument.DatabaseController.SetTableLocation(boTables[0],

boTable);<br />

<br />

//Verify the database after adding substituting the new table.<br />

//To ensure that the table updates properly when adding Command tables or Stored

Procedures.<br />

boReportDocument.VerifyDatabase();<br />

<br />

return boReportDocument;<br />

}</code></p>

<p>

<strong>SqlServer</strong><br />

<code>

//Add these required Crystal Assemblies to your project<br />

//CrystalDecisions.ReportAppServer.DataDefModel<br />

//CrystalDecisions.ReportAppServer.ClientDoc<br />

//CrystalDecisions.ReportAppServer.Controllers<br />

//CrystalDecisions.CrystalReports.Engine<br />

//CrystalDecisions.Shared<br />

<br />

//Add these Crystal Assemblies to the top of your code page<br />

using CrystalDecisions.ReportAppServer.DataDefModel;<br />

using CrystalDecisions.CrystalReports.Engine;<br />

using CrystalDecisions.Shared;<br />

<br />

private ReportDocument ChangeConnectionInfo()<br />

{<br />

ReportDocument boReportDocument = new ReportDocument();<br />

//*EDIT* Change the path and report name to the report you want to change.<br />

boReportDocument.Load(@&quot;c:\reports\yourreport.rpt&quot;,

OpenReportMethod.OpenReportByTempCopy);<br />

<br />

//Create a new Database Table to replace the reports current table.<br />

CrystalDecisions.ReportAppServer.DataDefModel.Table boTable = <br />

new CrystalDecisions.ReportAppServer.DataDefModel.Table();<br />

<br />

//boMainPropertyBag: These hold the attributes of the tables ConnectionInfo

object<br />

PropertyBag boMainPropertyBag = new PropertyBag();<br />

//boInnerPropertyBag: These hold the attributes for the QE_LogonProperties<br />

//In the main property bag (boMainPropertyBag)<br />

PropertyBag boInnerPropertyBag = new PropertyBag();<br />

<br />

//Set the attributes for the boInnerPropertyBag<br />

boInnerPropertyBag.Add(&quot;Auto Translate&quot;, &quot;-1&quot;);<br />

boInnerPropertyBag.Add(&quot;Connect Timeout&quot;, &quot;15&quot;);<br />

boInnerPropertyBag.Add(&quot;Data Source&quot;, &quot;localhost&quot;);<br />

boInnerPropertyBag.Add(&quot;General Timeout&quot;, &quot;0&quot;);<br />

boInnerPropertyBag.Add(&quot;Initial Catalog&quot;, &quot;your_data_base&quot;);<br />

boInnerPropertyBag.Add(&quot;Integrated Security&quot;, &quot;True&quot;);<br />

boInnerPropertyBag.Add(&quot;Locale Identifier&quot;, &quot;3082&quot;);<br />

boInnerPropertyBag.Add(&quot;OLE DB Services&quot;, &quot;-5&quot;);<br />

boInnerPropertyBag.Add(&quot;Provider&quot;, &quot;SQLOLEDB&quot;);<br />

boInnerPropertyBag.Add(&quot;Tag with column collation when possible&quot;, &quot;0&quot;);<br />

boInnerPropertyBag.Add(&quot;Use DSN Default Properties&quot;, &quot;False&quot;);<br />

boInnerPropertyBag.Add(&quot;Use Encryption for Data&quot;, &quot;0&quot;);<br />

<br />

//Set the attributes for the boMainPropertyBag<br />

boMainPropertyBag.Add(&quot;Database DLL&quot;, &quot;crdb_ado.dll&quot;);<br />

boMainPropertyBag.Add(&quot;QE_DatabaseName&quot;, &quot;your_data_base&quot;);<br />

boMainPropertyBag.Add(&quot;QE_DatabaseType&quot;, &quot;OLE DB (ADO)&quot;);<br />

//Add the QE_LogonProperties we set in the boInnerPropertyBag Object<br />

boMainPropertyBag.Add(&quot;QE_LogonProperties&quot;, boInnerPropertyBag);<br />

boMainPropertyBag.Add(&quot;QE_ServerDescription&quot;, &quot;localhost&quot;);<br />

boMainPropertyBag.Add(&quot;QE_SQLDB&quot;, &quot;True&quot;);<br />

boMainPropertyBag.Add(&quot;SSO Enabled&quot;, &quot;False&quot;);<br />

<br />

//Create a new ConnectionInfo object<br />

CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo boConnectionInfo =

<br />

new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo();<br />

//Pass the database properties to a connection info object<br />

boConnectionInfo.Attributes = boMainPropertyBag;<br />

//Set the connection kind<br />

boConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE;<br />

//*EDIT* Set the User Name and Password if required.<br />

boConnectionInfo.UserName = &quot;UserName&quot;;<br />

boConnectionInfo.Password = &quot;Password&quot;;<br />

//Pass the connection information to the table<br />

boTable.ConnectionInfo = boConnectionInfo;<br />

<br />

//Get the Database Tables Collection for your report<br />

CrystalDecisions.ReportAppServer.DataDefModel.Tables boTables;<br />

boTables =

boReportDocument.ReportClientDocument.DatabaseController.Database.Tables;<br />

<br />

//For each table in the report:<br />

// - Set the Table Name properties.<br />

// - Set the table location in the report to use the new modified table<br />

boTable.Name = &quot;TABLE1&quot;;<br />

boTable.QualifiedName = &quot;your_data_base.dbo.TABLE1&quot;;<br />

boTable.Alias = &quot;TABLE1&quot;;<br />

<br />

boReportDocument.ReportClientDocument.DatabaseController.SetTableLocation(boTables[0],

boTable);<br />

<br />

//Verify the database after adding substituting the new table.<br />

//To ensure that the table updates properly when adding Command tables or Stored

Procedures.<br />

boReportDocument.VerifyDatabase();<br />

<br />

return boReportDocument;<br />

}<br />

</code>

</p>

Former Member
0 Kudos

I am still struggling with a similar issue. Our large base of Crystal reports has been deployed to customers (since Crystal 4) with our own application system which resets the logon information to the customers' own database and user information. Our current deployment uses VS 2008, Crystal 11.5 runtime and CRAXDRT which we now understand is not supported with VS 2008.

We are trying to upgrade to Crystal 2008 and have successfully set logon information for ODBC and OLE DB references but have been unable to do some of the database relocation that we could previously in CRAXDRT. We have some reports that were able to be run both against an Access database or a SQL Server database. Is this still possible in the Crystal 2008 object model? If Inproc RAS is required, is that still freely distributable with the Crystal runtime? Is there any documentation that helps converting CRAXDRT code to the Crystal 2008 ReportDocument model? So far the only missing functionality I have found is the progress bar, but I worry about what's around the next corner in the conversion. Thanks for any help you can give.

former_member183750
Active Contributor
0 Kudos

InProc Ras is freely distributable.

Only documentation re. conversion I have is the following:

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d0479adb-6b3f-2b10-1e9c-eb81a157...

More RAS resources.

There is a utility on our ftp server that will give you the logon code you'd need for your reports. All you have to do is open the reprot with the utility and you will get VB and C# code. The utility is here:

https://sapmats-us.sap-ag.de/download/download.cgi?id=I8XEAX64QU762S0XC8J71OWPTWWJUQKHGZMNZMJSEFV7FJ...

Other resources;

Developer help file:

http://help.sap.com/businessobject/product_guides/boexir31/en/rassdk_net_dg_12_en.chm

Sample apps:

https://wiki.sdn.sap.com/wiki/display/BOBJ/NETRASSDK+Samples

How to Use The RAS SDK .NET With In-Process RAS Server:

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/10b840c0-623f-2b10-03b5-9d191386...

Ludek

Former Member
0 Kudos

<p>I thought it was solved but I have another issue with the subreports.<br />

Within a subreport the following line throws an exception:<br />

</p>

boReportDocument.ReportClientDocument.DatabaseController.SetTableLocation(boTables<i>, boTable);

Message = "Not supported within subreports."

at CrystalDecisions.ReportAppServer.SubreportWrapper.get_IsOpen()

at CrystalDecisions.CrystalReports.Engine.ReportDocument.get_IsLoaded()

at CrystalDecisions.CrystalReports.Engine.ReportDocument.get_ReportClientDocument()

<p>

Thank you very much.</p>

Edited by: jporcar on Feb 15, 2010 10:46 AM

former_member183750
Active Contributor
0 Kudos

Maybe to approach this is to save out the subreport and run it through the utility. See what the database logon should be for the subreport, then incorporate that into your project (?).

Ludek