private void button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection (@"Data Source=CONA-A07\SQLEXPRESS;Initial Catalog=Pics;Integrated Security=True;Pooling=False"); SqlCommand command = new SqlCommand ("select PicName from Pictures where PicID =1", con); //for retrieving the image field in SQL SERVER EXPRESS //Database you should first bring //that image in DataList or DataTable //then add the content to the byte[] array. //That's ALL! SqlDataAdapter dp = new SqlDataAdapter(command); DataSet ds = new DataSet("Pictures"); byte[] MyData = new byte[0]; dp.Fill(ds, "Pictures"); DataRow myRow; myRow = ds.Tables["Pictures"].Rows[0]; MyData = (byte[])myRow["PicName"]; MemoryStream stream = new MemoryStream(MyData); //With the code below, you are in fact converting the byte array of image //to the real image. pictureBox1.Image = Image.FromStream(stream,false ,true ); //System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms, false, true); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)