insert a picture (bmp) to data base (Access)

  • Thread starter Thread starter =?ISO-8859-2?Q?N_i_E_=B6_W_i_A_D_o_M_y?=
  • Start date Start date
?

=?ISO-8859-2?Q?N_i_E_=B6_W_i_A_D_o_M_y?=

Hello. I have a problem with insert a picture (bmp) to data base. I
wan't add picture to cell in data base (Access) like double decimal.

Someone have a idea how to make this?

Please help

MarianZED
 
Marian,

A complete sample, it creates a datatable with that the update using ADONET
is standard handling.

\\\needs a picturebox on a form
private void Form1_Load(object sender, System.EventArgs e)
{
OpenFileDialog fo = new OpenFileDialog();
if (fo.ShowDialog() == DialogResult.OK)
{
System.IO.FileStream fs = new System.IO.FileStream
(fo.FileName, System.IO.FileMode.Open);
System.IO.BinaryReader br = new System.IO.BinaryReader(fs);
Byte[] abyt = br.ReadBytes((int)fs.Length);
br.Close();
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.Add("image",Type.GetType("System.Byte[]"));
dt.Rows.Add(dt.NewRow());
dt.Rows[0]["image"] = abyt;
Byte[] abyt2 = (byte[]) dt.Rows[0][0];
System.IO.MemoryStream ms2 = new System.IO.MemoryStream(abyt2);
pictureBox1.Image = Image.FromStream(ms2);
}
}
}

I hope this helps a little bit?

Cor
 
Back
Top