Hi,
I have created a report file and deployed it on Crystal Reports Server 2008. Now I want to access this report from CRS and show in ASP.Net 4.0 application using CrystalReportViewer control. For achieving this, I wrote:
SessionMgr boSessionMgr = new SessionMgr();
string serverName = "SERVER";
//Log on credential for crystal report serevr
EnterpriseSession boEnterpriseSession = boSessionMgr.Logon("Administrator", "p@ssword", serverName, "secEnterprise");
InfoStore boInfoStore = (InfoStore)boEnterpriseSession.GetService("InfoStore");
InfoObjects boInfoObjects = boInfoStore.Query("SELECT * FROM CI_INFOOBJECTS WHERE SI_KIND='CrystalReport' And SI_NAME Like 'REPORT_NAME'");
CrystalDecisions.Enterprise.Desktop.Report report = null;
if (!Equals(boInfoObjects, null) && boInfoObjects.Count > 0)
report = (CrystalDecisions.Enterprise.Desktop.Report)boInfoObjects[1];
CrystalDecisions.Shared.ConnectionInfo connectionInfo = null;
CrystalDecisions.Shared.TableLogOnInfos tableLogonInfos = null;
CrystalDecisions.Shared.TableLogOnInfo tableLogonInfo = null;
tableLogonInfos = new CrystalDecisions.Shared.TableLogOnInfos();
connectionInfo = new CrystalDecisions.Shared.ConnectionInfo();
connectionInfo.ServerName = "DB_SERVER";
connectionInfo.DatabaseName = "DBNAME";
connectionInfo.UserID = "USERNAME";
connectionInfo.Password = "PASSWORD";
tableLogonInfo = new CrystalDecisions.Shared.TableLogOnInfo();
tableLogonInfo.ConnectionInfo = connectionInfo;
tableLogonInfos.Add(tableLogonInfo);
CrystalReportViewer1.EnterpriseLogon = boEnterpriseSession;
CrystalReportViewer1.LogOnInfo = tableLogonInfos;
CrystalReportViewer1.ReportSource = report;
CrystalReportViewer1.DataBind();
To get access to SessionMgr, EnterpriseSession classes etc, I installed crystal reports Server 2008 client components on my dev machine.
After adding reference ( version: 12.0.1100.0 ), I was able to reference these classes in code but the code started giving compile time error (Interop type 'CrystalDecisions.Enterprise.SessionMgr' cannot be embedded. Use the applicable interface instead.).
Please tell me if the CR Server 2008 is compatible with VS 2010 or not? OR Is there any mistake in how/what references are added in the project.
After this, I changed the target framework of my ASP.Net web app to 3.5 from 4.0. And voila, the project compiled fine after that.
Please tell me what changes will I have to do if I want to keep my application's target framework to 4.0? or Is it not possible to target 4.0 framework if we want to use CR server2008?
Will upgrading to Crystal server 2011 solve the issue?
Thanks in advance,
Manish Gupta