Click here to Skip to main content
15,868,164 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Posted
Updated 8-Feb-21 6:00am

1 solution

 
Share this answer
 
Comments
Amit Sharma (Patna) 8-Feb-21 12:50pm    
Sir, Thanking you for your reply.
But in datasource, i m setting a dataset having one or more than one datatable. Is it now required to set DB Logon?
thatraja 8-Feb-21 22:58pm    
Your report uses typed dataset(without database) way?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900