locked
Display more pictures in crystal report not work why RRS feed

  • Question

  • Hi guys i try to show picture of specified employee from network path in crystal report  it work

    but i don't know how to show all pictures to all employees in crystal report

    Can any one help me to customize my code to accept show all employee pictures

    i try to make this from crystal report and assign path but version of crystal report not allow to me

    to put path

    my code below show picture to one employee from text box control from network path

    I need to customize this code to accept show more one  pictures of employees from  employee table

    the following fields i show in report

    EmployeeNo      integer

    EmployeeName   nvarchar(50)

    Image     datatype  image 

    btnemployeeno_click

       DataTable dt = new DataTable();
    string connString = "data source=192.168.1.105; initial catalog=hrdata;uid=sa; password=1234";
    using (SqlConnection con = new SqlConnection(connString))
    {
    con.Open();
    SqlCommand cmd = new SqlCommand("ViewEmployeeNoR", con);
    cmd.CommandType = CommandType.StoredProcedure;    // Viewxxx doesn't seem a good name for a sp
    cmd.Parameters.Add("@EmployeeNo", SqlDbType.NVarChar, 20);
    cmd.Parameters["@EmployeeNo"].Value = textBox1.Text;
    SqlDataAdapter da = new SqlDataAdapter();
    da.SelectCommand = cmd;
    da.Fill(dt);
    }        
    string path = Path.Combine("\\\\192.168.1.105\\Personal Pictures", textBox1.Text) + ".jpg";
    FileStream fs=null;
    if (File.Exists(path))
    {
    fs = new FileStream("\\\\192.168.1.105\\Personal Pictures\\" + textBox1.Text + ".jpg", FileMode.Open);
    }
    else
    {
    MessageBox.Show("Please File Not Exist");
    }
    BinaryReader br = new BinaryReader(fs);
    byte[] imgbyte = new byte[fs.Length + 1];
    imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)));
    foreach (DataRow dr in dt.Rows)
    {
    dr["Image"] = imgbyte;
    }
    ReportDocument objRpt = new Reports.CrystalReportData2();
    objRpt.SetDataSource(dt);
    crystalReportViewer1.ReportSource = objRpt;
    crystalReportViewer1.Refresh();                     
    Tuesday, February 17, 2015 11:55 AM

Answers

  • These forums are for MS products. Questions related to third party products like Crystal Reports should be posted in their forums.
    • Proposed as answer by Barry Wang Wednesday, February 18, 2015 6:50 AM
    • Marked as answer by Just Karl Friday, February 27, 2015 8:28 PM
    Tuesday, February 17, 2015 6:42 PM

All replies

  • Hi, 

    Put an image field in your report, then change the image’s Graphic Location:
    right click the image, select Format Graphic, select Picture tab, click the conditional-formula button that look like a x2 and set the formula’s text to the name of the formula or parameter field that will contain the image’s URL.
    Save the formula and click the OK button. Save the report and test it.
    Be carefull with the size of the image field. If this size is not equal to the image itself it could get resized.

    Good Tutorial


    Mark as answer or vote as helpful if you find it useful | Ammar Zaied [MCP]

    Tuesday, February 17, 2015 3:34 PM
  • Thank you for reply

    my version of crystal report is not allow me to do that

    can any one help me to do that from code

    if possible

    i search about graphic location in picture tab not exist

    what i do to solve the proplem

    Tuesday, February 17, 2015 5:44 PM
  • These forums are for MS products. Questions related to third party products like Crystal Reports should be posted in their forums.
    • Proposed as answer by Barry Wang Wednesday, February 18, 2015 6:50 AM
    • Marked as answer by Just Karl Friday, February 27, 2015 8:28 PM
    Tuesday, February 17, 2015 6:42 PM