I wish to use the ReportDocument.Load() method to load the byte array object. Is that doable?

Megha Chourasiya 1 Reputation point
2021-06-17T06:53:19.577+00:00

Is there a way of loading byte array as ReportDocument without having to save it and use its location?

Details:

Let's say I have saved rpt file in ByteArray in database table, I wish to use the ReportDocument.Load() method to load the byte array object.

Is that doable, or do I have to save that object as a RPT file, then load it using the server path

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,415 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,640 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Chao Deng-MSFT 796 Reputation points
    2021-06-17T09:01:23.62+00:00

    Hi @Megha Chourasiya ,
    You need to save it and then load it using its path.

    using System;  
    using System.Drawing;  
    using System.Windows.Forms;  
    using CrystalDecisions.CrystalReports;  
    using CrystalDecisions.CrystalReports.Engine;  
    using CrystalDecisions.ReportSource;  
    using CrystalDecisions.Windows.Forms;  
      
    namespace myapp  
    {  
      
    public partial class tstfrm1 : Form  
    {  
        public tstfrm1()  
        {  
      
            InitializeComponent();  
      
            ReportDocument rptDoc = new ReportDocument();  
            rptDoc.Load(@"C:\CrystalReport1.rpt");  
            /*If you have a datasource, link it like below*/  
            //rptDoc.SetDataSource(dataset.Tables["tripsheet"]);  
            CrystalReportViewer crystalReportViewer1 = new CrystalReportViewer();  
            crystalReportViewer1.ReportSource = rptDoc;  
            crystalReportViewer1.Refresh();   
            this.Controls.Add(crystalReportViewer1);  
            crystalReportViewer1.Dock = DockStyle.Fill;  
        }  
    }  
    

    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards,

    ChaoDeng

    0 comments No comments