我已经检查了stackoverflow,google,youtube,msdn资源。 MSDN说,我需要使用picturebox并使用我的数据库并设置mime类型。我做到了这一点。但是Image并没有显示出来。
如何从数据库向Microsoft Report RDLC显示任何类型的图像,即jpg,png等?我已将图像作为二进制类型保存到数据库中。
ReportViewer.cs:
_connection.Open();
_aPatient = new Patient();
String QuearString = String.Format(
"SELECT ImageReportStorageTable.ImageOne From ImageReportStorageTable " +
" WHERE (ImageReportStorageTable.PrescriptionCode = 21)");
String baseString=null;
_command = new SqlCommand(QuearString, _connection);
SqlDataReader aReader = _command.ExecuteReader();
if (aReader.HasRows)
{
while (aReader.Read())
{
baseString = Convert.ToBase64String((byte[]) (aReader[0]));
}
}
_connection.Close();
ReportParameter paramLogo = new ReportParameter();
paramLogo.Name = "Image1";
paramLogo.Values.Add(baseString);
prescriptionReportViewer.LocalReport.SetParameters(paramLogo);
我已经将上面查询中返回的值用于报表查看器图像属性函数。
=System.Convert.FromBase64String(Parameters!Image1.Value)