0
votes

Created/Export PDF file using the Crystal Report in VS2012 in ASP.Net using C#.

CR Version: Crystal Report XI MVC Framework: 4.0 OS: Window 7 64 bit

The code is working properly in the developer machine but when I have uploaded my code in the client machine it throws errors.

In the client machine I have installed MVC Framework 4.0 and Crystal Reports runtime engine for .Net Framework(64-bit) and also installed SQL Server 2008 Native client.

Error List:

1) Could not load file or assembly 'CrystalDecisions.ReportAppServer.CommLayer, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified.

To resolve this issue uploaded all the dll for the Crystal report from the C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet

2) Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified. -> To resolve this I have installed Crystal Reports runtime engine for .Net Framework(64-bit)

3) Crystal report error Database Logon Failed Exception Details: System.Runtime.InteropServices.COMException: Database logon failed.

Got stuck in this error.

I have tried the following ways to resolve but could not get any solution. 1) Checked for the connection string properly.

string serverName = ConfigurationManager.AppSettings["ServerName"];
        rd.SetDatabaseLogon("userid", "password", serverName, 
        "databasename");
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.Type = ConnectionInfoType.CRQE;
connectionInfo.ServerName = serverName;
connectionInfo.DatabaseName = "Databasename";
connectionInfo.UserID = "userid";
connectionInfo.Password = "password";
connectionInfo.IntegratedSecurity = false;

TableLogOnInfo tableInfo = new TableLogOnInfo();
tableInfo.ConnectionInfo = connectionInfo;
foreach (Table table in rd.Database.Tables)
{
    table.LogOnInfo.ConnectionInfo = connectionInfo;
    table.ApplyLogOnInfo(tableInfo);
}

This is my code for connection string, tried with different ways but having the same issue.

And to check this locally, I have uploaded in IIS, it was working fine in the machine (i.e developer machine and also checked in my friend machine it was working properly as his PC was also a developer machine, but when checked in other PC it was not properly was throwing Database login error.

The difference in our PC was the in his PC SQL Server was not installed only SQL Server 2008 Native client was installed.

The issue is my Crystal Report is unable to connect to the database.

I have created Crystal Report in following ways:

1) Added the new item in the solution. Reports-> Selected Crystal Report
2) For connecting database in my report
   Right click on Database Fields-> Database Expert-> My Connection-> Server Name, showing me the dialog for OLE DB(ADO), selected my Server Name, Enter the User ID and Password and selected my Database and Integrated Security unchecked.

My friend PC is window 7 64 bit OS.

I have also to resolve this error in 32 bit OS.

1

1 Answers

0
votes

Have you added the references in web.config

<add assembly="CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" />
<add assembly="CrystalDecisions.ReportSource, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" />
<add assembly="CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" />
<add assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" />
<add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" />