cancel
Showing results for 
Search instead for 
Did you mean: 

What is the best way to run a CR report generically from a .Net application ?

costa-b
Explorer
0 Kudos

Hello:

I came across the issue I reported here:

Now I am confused because what I thought it would work it actually doesn't work in all cases.

I used code like this to set the connection and run any CR report in our system.

private ConnectionInfo CreateConnectionInfo()
{
ConnectionInfo connectionInfo = new ConnectionInfo();
//  connectionInfo.DatabaseName = "rdDev";
connectionInfo.UserID = _reportRequestInfo.ReportRunUser;
connectionInfo.Password = _reportRequestInfo.ReportRunPassword;
connectionInfo.ServerName = _reportRequestInfo.ReportRunInstance;
return connectionInfo;
}

private static void SetDbLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)
{
//  Database database = reportDocument.ReportClientDocument.DatabaseController.Database;
//  foreach (ISCRTable table in database.Tables)
//  {
//    _log.DebugFormat("table: {0}", table.QualifiedName);
//  
//  }

Tables tables = reportDocument.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
{
TableLogOnInfo tableLogonInfo = table.LogOnInfo;

_log.DebugFormat("table={0}, location={1}", table.Name, table.Location);

tableLogonInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(tableLogonInfo);
}

}

Digging more into the issue, I have I found code such as this one: crls/CrlsReportDocument.cs at master · chrishibler/crls · GitHub

or the one that is generated by Ludek's utility (very similar with the code from the previous link) that sets all sorts of properties and it makes use of the RAS Server classes

Do I need to code this way or the other way? It seems that my way of doing it has the issue that it doesn't retain the original report table schema names.

Basically there are two sets of objects, one under the CrystalDecisions.ReportAppServer.DataDefModel and the other one under CrystalDecisions.CrystalReports.Engine. When do I use one and when do I use the other?

I looked with .Net reflector and the objects under CrystalDecisions.CrystalReports.Engine seem to be wrappers of objects under CrystalDecisions.ReportAppServer.DataDefModel. Why have two sets of objects? I personally find it confusing.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

HI Costa,

CR does not support Oracle synonyms. To use RAS you have to add the assemblies.

Click on the Overview tab and on the left you'll see a link to get samples, RAS samples are there, download them and try some of them. It will answer a lot of your questions on how to....

Don

costa-b
Explorer
0 Kudos

Hi, Don:

Not sure why you thought of synonyms - perhaps based on my other message. It is true that some of the tables referenced in the report had synonyms, others didn't though. Do you think that the CR runtime, once it detects synonyms, it tries to detect the schema of a table?

Thanks

0 Kudos

I don't know, we don't support them so I never tried...

Use reports based on tables only and if using Stored Procedures the use ODBC, Oracles OLE DB provide has problems with SP's.


Answers (0)