SAP Knowledge Base Article - Public

1199408 - How to load an image from disk into a dataset using CSharp (C#) in Visual Studio .NET


How can you load an image from disk into a dataset using CSharp (C#) in Visual Studio .NET?


To load an image into a DataSet, use the following code:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CrystalDecisions.CrystalReports.Engine;
public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
//Load image from disk into dataset
MyDataSet myDataSet = new MyDataSet();

        System.IO.BinaryReader binaryReader =  new System.IO.BinaryReader(new System.IO.FileStream(Server.MapPath("image.jpeg"),System.IO.FileMode.Open)); 
myDataSet.Images.AddImagesRow(binaryReader.ReadBytes(Convert.ToInt32(new System.IO.FileInfo(Server.MapPath("image.jpeg")).Length)));
        //Prepare report
ReportDocument reportDocument = new ReportDocument();


If the code sample is truncated in your browser window, copy and paste the entire block of code into a text editor. Code samples are intentionally formatted this way so they do not wrap. Wrapped code can produce unexpected errors in your application.


This code snippet is meant as an example only and is not a supported BusinessObjects product. All custom code should be thoroughly tested in your own development environment prior to using in production.


dataset image VS2005 load , 3784723 , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To


SAP Crystal Reports, developer version for Microsoft Visual Studio ; SAP Crystal Reports, version for Visual Studio .NET 2008