Click here to Skip to main content
15,867,750 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to display the varbinary data on a crystal report after converting it to original bytes. The content that I saved is a pdf content. I followed this approach to achieve as per my requirement

Crystal Reports Display Images From Database Asp.Net[^]

So can some one help me how can I display byte[] data on to the report

What I have tried:

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyCon"].ConnectionString);
string strSelect = "SELECT FileData from Documents where ID = 26";
SqlCommand cmd = new SqlCommand(strSelect, con);
SqlDataAdapter dAdapter = new SqlDataAdapter(cmd);
con.Open();
dAdapter.Fill(dsReport.Tables["Documents"]);
Byte[] bytes = (Byte[])dsReport.Tables[0].Rows[0]["FileData"];
dsReport.Tables[0].Rows[0]["FileData"] = bytes;
dsReport.AcceptChanges();
con.Close();
CrystalReport1 rpt = new CrystalReport1();
rpt.SetDataSource(dsReport);
crystalReportViewer1.ReportSource = rpt;
Posted
Comments
Mycroft Holmes 25-Sep-16 23:10pm    
I am pretty certain you cannot display a PDF within a report. The report viewer will know how to render an image converted from binary but will not be able to deal with a PDF.

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