[英]Image won't appear in crystal reports
I wonder how can I display the Images in the column "DVDImage". 我想知道如何在“ DVDImage”列中显示图像。 The report works fine, its just the image wont appear.
该报告工作正常,它的图像不会出现。 Do I have to convert the image to bytes?
我必须将图像转换为字节吗? how can I put it into the listview after converting to bytes?
转换为字节后如何将其放入列表视图?
Here's my code: 这是我的代码:
public void PrintDVDList(frmReportDVDList frmReportDVDList)
{
con.Open();
DataTable dt = new DataTable();
DataSet ds = new DataSet();
ds.Tables.Add(dt);
OleDbDataAdapter da = new OleDbDataAdapter("SELECT ItemCode, Title, Genre, Film, YearReleased, Classification, NumberOfDiscs, DVDImage FROM tblDVDInventory ORDER BY Title", con);
da.Fill(dt);
ListView LV = new ListView();
if (dt.Rows.Count > 0)
{
for (int ctr = 0; ctr <= dt.Rows.Count - 1; ctr++)
{
ListViewItem Item = new ListViewItem();
Item.Text = dt.Rows[ctr]["ItemCode"].ToString();
Item.SubItems.Add(dt.Rows[ctr]["Title"].ToString());
Item.SubItems.Add(dt.Rows[ctr]["Genre"].ToString());
Item.SubItems.Add(dt.Rows[ctr]["Film"].ToString());
Item.SubItems.Add(dt.Rows[ctr]["YearReleased"].ToString());
Item.SubItems.Add(dt.Rows[ctr]["Classification"].ToString());
Item.SubItems.Add(dt.Rows[ctr]["NumberOfDiscs"].ToString());
Item.SubItems.Add(dt.Rows[ctr]["DVDImage"].ToString());
LV.Items.Add(Item);
}
}
con.Close();
rptDVDList Report = new rptDVDList();
Report.SetDataSource(ds.Tables[0]);
frmReportDVDList.crvDVDList.ReportSource = Report;
frmReportDVDList.crvDVDList.Refresh();
}
This is the sample code I normally suggest looking at when getting started with Crystal Reports in C#: 这是我通常建议在C#中使用Crystal Reports时要查看的示例代码:
using System;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
ReportDocument cryRpt = new ReportDocument();
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables ;
cryRpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt");
crConnectionInfo.ServerName = "YOUR SERVER NAME";
crConnectionInfo.DatabaseName = "YOUR DATABASE NAME";
crConnectionInfo.UserID = "YOUR DATABASE USERNAME";
crConnectionInfo.Password = "YOUR DATABASE PASSWORD";
CrTables = cryRpt.Database.Tables ;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
crystalReportViewer1.ReportSource = cryRpt;
crystalReportViewer1.Refresh();
}
}
}
From: http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-dynamic-login.htm 来自: http : //csharp.net-informations.com/crystal-reports/csharp-crystal-reports-dynamic-login.htm
You can see by passing connection info in the code the user will not be prompted. 您可以通过在代码中传递连接信息来查看,系统不会提示用户。 There is no need to use an intermediate dataset.
无需使用中间数据集。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.