Click here to Skip to main content
11,428,876 members (60,250 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# CrystalReports
how to insert image in access database How to show image dynamically in crystal report c#
Posted 9-May-11 2:51am
Edited 22-May-11 23:32pm
ambarishtv10.5K
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

 private void Submit_Click(object sender, EventArgs e)
        {
            byte[] picbyte = System.IO.File.ReadAllBytes(textBox.Text);
            try
            {
                string constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\\PIS(ACU).mdb;";
                Con = new OleDbConnection(@constr);
                Con.Open();
                Com = new OleDbCommand();
                Com.Connection = Con;
                Com.CommandText = "INSERT INTO Pics(Patient_Id,ImageDate,Photo)VALUES(" + txtPatientId.Text + ",'" + txtImageDate.Value.ToString("yyyy/MM/dd HH:mm:ss") + "', @Photo)";
                OleDbParameter picParam = Com.Parameters.Add("@Photo", SqlDbType.Binary);
                picParam.Value = picbyte.ToArray();
                picParam.Size = picbyte.ToArray().Length;
                Com.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Con.Close();
                MessageBox.Show("Image Uploaded Successfully", "PIS System");
                 DiseaseRecord D = new DiseaseRecord();
                 D.Show();
                 this.Close();
            }
        }
 

        private void btnBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog fd = new OpenFileDialog();
            fd.InitialDirectory = "c:\\";
           // DialogResult Result = fd.ShowDialog();
            if (fd.ShowDialog() == DialogResult.OK)
            {
                textBox.Text = fd.FileName.ToString();
                pictureBox.ImageLocation = textBox.Text;
            }
            Console.ReadLine();
        }
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web01 | 2.8.150428.2 | Last Updated 7 Oct 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100