I am using Crystal Report IN MVC 5 but it throw an error that is.
1. Make a simple file test.rpt with using of Repository and want to show only PartyCode and PartyName
2. Following is code in action:
using CrystalDecisions.CrystalReports.Engine;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LogisticMVC.ClassCollections;
namespace LogisticMVC.Controllers
{
public class CRController : Controller
{
// GET: CR
clsCommon cls = new clsCommon();
public ActionResult ManifestPrint(int ManifestNo)
{
ReportDocument rd = new ReportDocument();
rd.Load(Server.MapPath("~/Reports/test.rpt"));
DataTable dt = new DataTable();
DataSet ds = new DataSet();
string astr = "";
astr = "Select * from PartyMaster where AccountGroup=2";
dt = new DataTable();
dt = cls.FillDataTable(astr);
dt.TableName = "ConsigneeParty";
ds.Tables.Add(dt);
rd.SetDataSource(ds);
Response.Buffer = false;
Response.ClearContent();
Response.ClearHeaders();
Stream stream =
rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "application/pdf", "test.pdf");
Now following is error on "rd.SetDataSource(ds)"
An exception of type 'CrystalDecisions.CrystalReports.Engine.DataSourceException' occurred in CrystalDecisions.ReportAppServer.DataSetConversion.dll but was not handled in user code
Additional information: Error in File test 2480_12748_{ADE96ED9-02AE-42F9-A1C3-CD6458953B01}.rpt:
Failed to load database information.
In web.config, there is only only setting found e.g.
<dependentassembly>
<assemblyidentity name="CrystalDecisions.Shared" publickeytoken="692fbea5521e1304" culture="neutral">
<bindingredirect oldversion="0.0.0.0-13.0.4000.0" newversion="13.0.4000.0">
I have Used Nuget to add crystal reprot.
What I have tried:
checked table etc. but not found any solution.
plz help