ahmed sa

ahmed sa

  • NA
  • 289
  • 128.9k

How to add image from local disk to crystal report 2008

Oct 26 2014 4:39 AM

Hi guys i have proplem
I create crystal report(blank report) to show the data of employee from database hrdata on table Employee based on stored procedure
his name is ShowEmployee
when he write EmployeeNo in textbox1 control show employee detailes
as name,address,nationality,branch,join date,birth date,personal picture
but personal picture field not exist in database so that i need to show the picture from local
path from local hard disk
Meaning when i write in textbox1 employee no as 1233 show
1- detailes from database and that i already done
2-show image from local hard disk based on textbox1 (employee no) not done
i need code by c# to show image in crystal report from local drive based on employee no
how i do that
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Shared;
using CrystalDecisions.Windows.Forms;

namespace FleetManagment
{
    public partial class ShowEmployeeRecord : Form
    {
       
        public ShowEmployeeRecord()
        {
            InitializeComponent();
           
        }
private Reports.DateBaseReport objMyReport;      
private ConnectionInfo objConnectionInfo;     
private void setSQLParams()
{
ParameterField objParameterField =
crystalReportViewer1.ParameterFieldInfo[0];
ParameterDiscreteValue objParameterDiscreteValue;
objParameterDiscreteValue = new ParameterDiscreteValue();
objParameterDiscreteValue.Description = "@EmployeeNo";
objParameterDiscreteValue.Value = Convert.ToDateTime (textbox1.text);
objParameterField.CurrentValues.Add(objParameterDiscreteValue);
crystalReportViewer1.ParameterFieldInfo.Add(objParameterField);
objParameterField = crystalReportViewer1.ParameterFieldInfo[1];
}

private void setDatabaseSettings()
{
objConnectionInfo = new ConnectionInfo();
objConnectionInfo.ServerName = "192.168.1.5";
objConnectionInfo.DatabaseName = "hrdata";
objConnectionInfo.UserID = "sa";
objConnectionInfo.Password = "1234";
}


private void refreshReport()
{          
Tables tables =Tables tables = objMyReport.Database.Tables;
foreach (Table tbl in tables)
{
TableLogOnInfo objTableLogOnInfo = new TableLogOnInfo();
objTableLogOnInfo.ConnectionInfo = objConnectionInfo;
tbl.ApplyLogOnInfo(objTableLogOnInfo);
}        
crystalReportViewer1.ReportSource = objMyReport;         
setSQLParams();
}


private void crystalReportViewer1_ReportRefresh(object source, CrystalDecisions.Windows.Forms.ViewerEventArgs e)
{
e.Handled = true;         
((ReportClass)crystalReportViewer1.ReportSource).Refresh();  
}

private void button2_Click(object sender, EventArgs e)
{
objMyReport = new Reports.DateBaseReport();       
setDatabaseSettings();        
refreshReport();

}
}
}



Answers (2)