水晶报告动态图像没有显示

时间:2010-08-25 12:12:53

标签: c# asp.net crystal-reports

我正在尝试在水晶报表上显示数据集xsd中的图像,但它没有显示图像。请帮我。

此致 Riyaz

    string sql = "select * from ImageUpload";
    SqlDataAdapter da = new SqlDataAdapter(sql, strConn);
    DataSet ds = new DataSet();
    da.Fill(ds, "Image");       

    for (int index = 0; index < ds.Tables[0].Rows.Count; index++)
    {
        if (ds.Tables[0].Rows[index]["thumb_path"].ToString() != "")
        {
            //if (File.Exists(Server.MapPath("~/129204153594EFF/Image13.jpg") +
            //    ds.Tables[0].Rows[index]["thumb_path"].ToString()))

            if (File.Exists(Server.MapPath("~/129204153594EFF/Image13.jpg")))
            {
                LoadImage(ds.Tables[0].Rows[index], "image_stream",
                    Server.MapPath("~/129204153594EFF/Image13.jpg"));
            }
        }
    }

    // ReportDocument crReportDocument = BLL.BusinessLogicLayer.Globals.GetReportDocument("rport.rpt");

    ReportDocument crReportDocument = BLL.BusinessLogicLayer.Globals.GetReportDocument("rport.rpt");

    crReportDocument.SetDataSource(ds.Tables[0]);
    CrystalReportViewer1.ReportSource = crReportDocument;   
}

private void LoadImage(DataRow objDataRow, string strImageField, string FilePath)
{
    try
    {
        FileStream fs = new FileStream(FilePath, System.IO.FileMode.Open,
        System.IO.FileAccess.Read);
        byte[] Image = new byte[fs.Length];
        fs.Read(Image, 0, Convert.ToInt32(fs.Length));
        fs.Close();
        objDataRow[strImageField] = Image;
    }
    catch (Exception ex)
    {
        //Handler
    }
}

1 个答案:

答案 0 :(得分:-1)

使用相应的水晶报告令牌和版本添加此内容,您最好转到web.config文件