Click here to Skip to main content
12,952,725 members (37,346 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
how to insert image in access database How to show image dynamically in crystal report c#
Posted 9-May-11 1:51am
Updated 22-May-11 22: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)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,289
CHill60 3,490
Maciej Los 3,103
Jochen Arndt 1,975
ppolymorphe 1,900


Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 7 Oct 2013
Copyright © CodeProject, 1999-2017
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