Store Image in Database....
MemoryStream ms = new MemoryStream();
Bitmap bmpImage = new Bitmap(pictureBox1.Image);
bmpImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] data = ms.GetBuffer();
string ss= data.ToString();
string cb = "insert into demopic values('"+ss+"','')";
Retrive image from database
DataGridViewRow dr = dataGridView1.SelectedRows[0];
byte[] data = (byte[])dr.Cells["pic"].Value;
MemoryStream ms = new MemoryStream(data);
pictureBox1.Image = Image.FromStream(ms);
MemoryStream ms = new MemoryStream();
Bitmap bmpImage = new Bitmap(pictureBox1.Image);
bmpImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] data = ms.GetBuffer();
string ss= data.ToString();
string cb = "insert into demopic values('"+ss+"','')";
Retrive image from database
DataGridViewRow dr = dataGridView1.SelectedRows[0];
byte[] data = (byte[])dr.Cells["pic"].Value;
MemoryStream ms = new MemoryStream(data);
pictureBox1.Image = Image.FromStream(ms);
No comments:
Post a Comment