如何在数据库中显示水晶报表中的图像 [英] how to display image in crystal report from database

查看:99
本文介绍了如何在数据库中显示水晶报表中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

我的名字是sudeshna。我想在我的水晶报告中显示序列号产品名称和产品图片,成本价格



图像存储在数据库中。



我想从数据库中检索并在水晶报告中显示。



我从谷歌做了很多研究,没找到确切的我想要的是什么。



如果有人可以帮助我,我将不得不承担责任。



我去了到解决方案资源管理器,然后添加项目 - >然后点击水晶报告 - >那么标准报告 - >选择db->然后表 - >然后字段然后格式化字段。



所有数据都来自其他字段,除了图像字段,只有图像的名称来源



请告诉我如何在水晶报告中显示图像





谢谢

Sudeshna

Hi
My name is sudeshna. i want to display serial number product name and product image, cost price in my crystal report

The images getting stored in database.

I want to retrieve from database and display in crystal report.

I have done a lot of research from google, didn't find exact what i want.

So i will be obliged if any one can help me.

I went to solution explorer,then add item-> then clicked crystal report-> then standard report-> chose db->then tables-> then fields and then formatted the fields.

all data are coming in other fields except in image field, only name of the image coming

please let me know how to display image also in crystal report


Thanks
Sudeshna

推荐答案

使用Image DataType在Sql数据库中存储图像

Use Image DataType to store Image in Sql Database
protected void SaveImage_Click(object sender, EventArgs e)
{
    if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "")
    {
        byte[] img = new byte[FileUpload1.PostedFile.ContentLength];
        HttpPostedFile Image = FileUpload1.PostedFile;
        Image.InputStream.Read(img, 0, (int)FileUpload1.PostedFile.ContentLength);
        string str = "insert img values(@img)";
        SqlConnection cn = new SqlConnection("data source=localhost;initial catalog=DBName;user id=sa;password=password");
        cn.Open();
        SqlCommand cmd = new SqlCommand(str, cn);
        cmd.Parameters.AddWithValue("@img", img);
        SqlDataReader dr = cmd.ExecuteReader();
        cn.Close();
    }
}







protected void ViewReport_Click(object sender, EventArgs e)
{
    SqlConnection cn = new SqlConnection("data source=localhost;initial catalog=DBName;user id=sa;password=password");
    cn.Open();
    SqlDataAdapter cmd = new SqlDataAdapter("select * from img", cn);
    DataTable dt = new DataTable();
    cmd.Fill(dt);
    string file = Server.MapPath("") + "\\CrystalReport.rpt";
    CrystalDecisions.CrystalReports.Engine.ReportDocument orpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
    orpt.Load(file);
    orpt.SetDataSource(dt);
    CrystalReportViewer1.ReportSource = orpt;
    //CrystalReportViewer1.DataBind();
}


这篇关于如何在数据库中显示水晶报表中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆