private void button1_Click(object sender, EventArgs e) { OleDbConnection myConnection = new OleDbConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); myConnection.Open(); OleDbCommand cmd = new OleDbCommand("select * from [Images] where ID=1", myConnection); OleDbDataAdapter da = new OleDbDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { if (dt.Rows[0]["AImage"] != DBNull.Value) { pictureBox.Image = ByteArrayToImage((Byte[])dt.Rows[0]["AImage"]); } } myConnection.Close(); } Bitmap ByteArrayToImage(byte[] b) { MemoryStream ms = new MemoryStream(); byte[] pData = b; ms.Write(pData, 0, Convert.ToInt32(pData.Length)); Bitmap bm = new Bitmap(ms, false); ms.Dispose(); return bm; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)