简体   繁体   中英

Setting Parameter To Crystal report ASP.net MVC c#

This is my code :

[HttpGet]
    public ActionResult Report(string id)
        {
            ReportClass rptH = new ReportClass();
            rptH.FileName = AppDomain.CurrentDomain.BaseDirectory + "Reports\\" + id + ".rpt";
            rptH.Load();
             rptH.SetParameterValue(0, "179");
            // rptH.SetParameterValue("Center", "103");
            // rptH.SetDataSource();

            Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            return File(stream, "application/pdf");   
        }

I'm trying to passing parameter to crystal report but I got this error :

System.Runtime.InteropServices.COMException: Connexion Failed.

At this line :

Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

As I think the problem is due to rptH.setParameterValue line it work's but not showing what I want.

How to fix that please.

似乎文件制作不成功,调试您的代码以确认您已成功建立与数据库的连接并且rptH有效

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM