Crystal Reports Does Not Display BLOB Field Correctly in IBlobField Control Using Crystal Reports fo

Discussion in 'Microsoft Dot NET' started by Jeff, May 4, 2006.

  1. Jeff

    Jeff Guest

    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!!!!
     
    Jeff, May 4, 2006
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. B. Harwood

    Crystal Reports.NET vs. Crystal Reports 9

    B. Harwood, Nov 28, 2003, in forum: Microsoft Dot NET
    Replies:
    0
    Views:
    319
    B. Harwood
    Nov 28, 2003
  2. Winston

    Crystal Reports BLOB Object image error!

    Winston, Dec 18, 2003, in forum: Microsoft Dot NET
    Replies:
    0
    Views:
    519
    Winston
    Dec 18, 2003
  3. Stu
    Replies:
    2
    Views:
    1,410
  4. Guest

    Insert BLOB using System.Data.ODBC

    Guest, Nov 26, 2005, in forum: Microsoft Dot NET
    Replies:
    3
    Views:
    627
    Paul Clement
    Nov 30, 2005
  5. Guest
    Replies:
    5
    Views:
    319
    Christopher Reed
    Feb 18, 2006
Loading...

Share This Page