SqlConnection conn = new SqlConnection(Properties.Settings.Default.SadiqueTestConnectionString);
SqlCommand cmd = new SqlCommand("SELECT Img FROM ImageTB ", conn);
SqlDataAdapter sqlDA = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sqlDA.Fill(ds, "ImageTB");
int c = ds.Tables["ImageTB"].Rows.Count;
if (c > 0)
{
Byte[] byteImageData = new Byte[0];
byteImageData = (Byte[])(ds.Tables["ImageTB"].Rows[c - 1]["Img"]);
MemoryStream stmBLOBData = new MemoryStream(byteImageData);
pictureBox1.Image = Image.FromStream(stmBLOBData);
conn.Close(); conn.Open();
cmd = new SqlCommand("INSERT INTO ImageTB (Img) VALUES (@Img)", conn);
cmd.Parameters.AddWithValue("Img", byteImageData).SqlDbType = SqlDbType.Image;
cmd.ExecuteNonQuery();
}