To browse image.. <pre lang="cs">private void button2_Click(object sender, EventArgs e) { try { OpenFileDialog of = new OpenFileDialog(); DialogResult d = of.ShowDialog(); of.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp; if (d == DialogResult.OK) { pictureBox1.Image = Image.FromFile(of.FileName); pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; imaeg = of.FileName; } } catch (Exception ex) { MessageBox.Show("upload only jpg image!!"); } } To save image... try { OleDbCommand cmd = new OleDbCommand("insert into Student values(@Myimage,@School)", conn); conn.Open(); cmd.Parameters.AddWithValue("@Myimage", imaeg); conn.close(); In my second form i wana show all the information of student with their image in datagridview image column. I am using the following code to retrive image: private void button1_Click(object sender, EventArgs e) { MemoryStream ms = new MemoryStream(); conn.Open(); OleDbCommand cmd = new OleDbCommand("Select Myimage from student", conn); byte[] image = (byte[])cmd.ExecuteScalar(); ms.Write(image, 0, image.Length); foreach (DataGridViewRow row in dataGridView1.Rows) { row.Cells[0].Value = image.ToString(); } Bitmap bitmap = new Bitmap(ms); dataGridView1.DataSource= bitmap; conn.Close(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)