if (Request.QueryString["ProductID"] != null) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ProdDB"].ConnectionString); string query = "SELECT ProductID, ProductName, ProductImage FROM Product"; SqlDataAdapter da = new SqlDataAdapter(query, con); DataTable dt = new DataTable(); da.Fill(dt); for (int i = 0; i < dt.Rows.Count; i++ ){ if (dt != null) { Byte[] bytes = (Byte[])dt.Rows[i]["ProductImage"]; Response.Buffer = true; Response.Charset = ""; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "Image/png"; Response.AddHeader("content-disposition", "attachment;filename=" + dt.Rows[i]["ProductName"].ToString()); Response.BinaryWrite(bytes); Response.Flush(); } } Response.Flush(); Response.End (); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)