SqlConnection connect = new SqlConnection(@"Data Source=USER;Initial Catalog=SAVERETRIVEDEMO;Integrated Security=True"); SqlCommand command = new SqlCommand ("select Image from save&Retriveimagedemo where ID=1", connect); //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("MyImages"); byte[] MyData = new byte[0]; dp.Fill(ds, "MyImages");(HERE I GOT ERROR INCORRECT SYNTAX NEAR SAVE KEYWORD) DataRow myRow; myRow = ds.Tables["MyImages"].Rows[0]; MyData = (byte[])myRow["fldPic"]; MemoryStream stream = new MemoryStream(MyData); //With the code below, you are in fact converting the byte array of image //to the real image. pictureBox2.Image = Image.FromStream(stream); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)