Bitmap bmp = new Bitmap(ms,false); Can anyone help me? In the access database the type is OLE Object. Thanks in advance Just to be clear, the error is in Bitmap bmp = new Bitmap(ms,false); What I have tried: <pre> try { cn.Open(); cmd = new OleDbCommand("select * from [EQUIVALENCE TABLE]", cn); da = new OleDbDataAdapter(cmd); da.Fill(dt); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { if (dr["Img"] != DBNull.Value) { img = ByteArrToImg((Byte[])dr["Img"]); Bitmap bitmap = new Bitmap(img); Graphics graphics = Graphics.FromImage(bitmap); graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.Flush(); bitmap.Save(path + "\\" + dr["file"].ToString() + ".jpg"); graphics.Dispose(); img.Dispose(); lblfile.Text = dr["file"].ToString(); } } } cn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); EventLog EL = new EventLog("ABS"); EL.Source = "ABS"; EL.WriteEntry(ex.ToString()); }
Bitmap ByteArrToImg(byte[] b) { try { MemoryStream ms = new MemoryStream(); ms.Position = 0; byte[] imgData = b; ms.Write(imgData, 0, Convert.ToInt32(imgData.Length)); Bitmap bmp = new Bitmap(ms,false); ms.Dispose(); return bmp; } catch(Exception er) { MessageBox.Show(er.Message); return null; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)