By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,436 Members | 2,958 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,436 IT Pros & Developers. It's quick & easy.

Crystal Reports Does Not Display BLOB Field Correctly in IBlobField Control Using Crystal Reports for VS.NET 2003

P: n/a
Help!!!

The bitmap I am trying to display in a sample Crystal Report is coming
up with much less quality than the original bitmap.

I have a 300x300 dpi bitmap file that I want to insert at run time into
a Crystal Report. The path to the file is stored in a varchar(100)
field in a table in SQL Server.

The Crystal Report displays the bitmap in the IBlobField object but it
is distorted and its resolution is much less than 300x300 dpi.

I created an .xsd file to represent a strongly typed dataset that was
used in order to design the Crystal Report. The column used to
populate the bitmap is of datatype "base64binary". It is also relevant
to note that the size of the IBlobField column that will be used to
display the bitmap has the same size dimension (3 inches wide x 1 inch
height) as the original bitmap.

The following C# code uses the path to the bitmap file, reads it into a
byte array, and then creates a DataTable that will be the source for
the Crystal Report. The properties of the Crystal Report Viewer
control are set in order to display the report.

Here is the code:

private void Form1_Load(object sender, System.EventArgs e)
{
// read bitmap file into Byte Array
String sPhotoFileName;
byte[] PhotoData;
sPhotoFileName = ConfigurationSettings.AppSettings["PhotoFilePath"] +
@"\Photo.BMP";

if (File.Exists(sPhotoFileName) == true)
{
FileStream fs = new
FileStream(sPhotoFileName,FileMode.Open,FileAccess .Read);

BinaryReader r = new BinaryReader(fs);
PhotoData = r.ReadBytes((int)fs.Length);

r.Close();
fs.Close();
}
else
{
PhotoData = null;
}

// create DataTable
DataTable dtEmployees = new DataTable();

dtEmployees.Columns.Add("EmployeeID",typeof(int));
dtEmployees.Columns.Add("LastName",typeof(string)) ;
dtEmployees.Columns.Add("FirstName",typeof(string) );
dtEmployees.Columns.Add("Photo",typeof(byte[]));

DataRow dr = dtEmployees.NewRow();

dr["EmployeeID"] = 123;
dr["LastName"] = "Schwartzmann";
dr["FirstName"] = "Jeff";

if (PhotoData != null)
{
dr["Photo"] = PhotoData;
}
else
{
dr["Photo"] = DBNull.Value;
}

dtEmployees.Rows.Add(dr);

// run Crystal Report
String sCrystalReportFileName;

sCrystalReportFileName =
ConfigurationSettings.AppSettings["CrystalFilePath"] +
@"\CrystalReport1.rpt";

ReportDocument oRpt = new ReportDocument();
oRpt.Load(sCrystalReportFileName);
oRpt.SetDataSource(dtEmployees);

crViewer.DisplayGroupTree = false;
crViewer.ReportSource = oRpt;

}
Thanks in advance for your help!!!!

May 4 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.