Print Page | Close Window

Loading report failed in ASP.NET with CR Server XI

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2022
Forum Name: Data Connectivity
Forum Discription: How to connect to data sources and export reports
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=2852
Printed Date: 18 Apr 2025 at 10:49pm


Topic: Loading report failed in ASP.NET with CR Server XI
Posted By: antonmaju
Subject: Loading report failed in ASP.NET with CR Server XI
Date Posted: 08 Apr 2008 at 7:53am
Hi, I have a problem with loading .rpt in my ASP.NET application. I'm using .Crystal Reports Server XI as my report repository. My development machine is using Windows XP SP2 and  the production server is using Windows Server 2003. My application works fine in development machine but I got "Database logon failed" message in production server. I have set database login & access rights, web.config and data source location in my .rpt to match the target machine so I don't how  this can be happened. I have tried using Windows authentication too but it didn't work

Here is my code:

// InfoStoreConnectionHelper is a custom class to handle connection with Infostore
// the report id is passed from another page
ReportApplicationServer.InfoStoreConnectionHelper helper = new ReportApplicationServer.InfoStoreConnectionHelper();
using (helper)
{
    //get client document by reportId
      CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocument doc = helper.GetClientDocumentByID(id);
    if (doc != null)
      {
           CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag props = new CrystalDecisions.ReportAppServer.DataDefModel.PropertyBagClass();
           CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfos info = new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfos();
           CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo ci = new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfoClass();
           props.Add("Data Source", ConfigurationManager.AppSettings["report_servername"]);
           props.Add("Initial Catalog", ConfigurationManager.AppSettings["report_dbname"]);
           ci.Attributes = props;
           ci.UserName = ConfigurationManager.AppSettings["report_username"];
           ci.Password = ConfigurationManager.AppSettings["report_password"];
           info.Add(ci);

         CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag pb = new CrystalDecisions.ReportAppServer.DataDefModel.PropertyBagClass();
           CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag lpb = new CrystalDecisions.ReportAppServer.DataDefModel.PropertyBagClass();
           lpb.Add("Data Source", ConfigurationManager.AppSettings["report_servername"]);
           lpb.Add("Initial Catalog", ConfigurationManager.AppSettings["report_dbname"]);
           lpb.Add("Provider", "SQLOLEDB");

           pb.Add("Database DLL", "crdb_ado.dll");
           pb.Add("QE_DatabaseType", "OLE DB (ADO)");
           pb.Add("QE_LogonProperties", lpb);
           pb.Add("QE_SQLDB", "true");

           CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo nci = new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfoClass();
           nci.UserName = ConfigurationManager.AppSettings["report_username"];
           nci.Password = ConfigurationManager.AppSettings["report_password"];
           nci.Kind = CrystalDecisions.ReportAppServer.DataDefModel.CrConnectionInfoKindEnum.crConnectionInfoKindCRQE;
           nci.Attributes = pb;
           foreach (CrystalDecisions.ReportAppServer.DataDefModel.Table tbl in doc.Database.Tables)
           {
                   tbl.ConnectionInfo = nci;
           }
                    
           crViewer.ReportSource = doc;
    }
}

Please help me.



Print Page | Close Window