title: how to download an image stored in sql server
body: <p>I am working on a web application where have stored images in sql server DB. I have used 'Image' datatype to store the images in the table. When user clicks on a button i want to give "open with/save as" option. How to do that in c# asp.net?</p>
  
  <p>the code that i am using is below</p>
  
  <pre><code> conn = connect.getConnection();
   selcmd = new System.Data.SqlClient.SqlCommand("select image from tblQuestion where qid=" + context.Request.QueryString["qid"], conn);
            conn.Open();
            rdr = selcmd.ExecuteReader();
            while (rdr.Read())
            {
              context.Response.ContentType = "image/jpg";
              context.Response.AddHeader("content-disposition","attachment;filename=Tr.png");
              context.Response.BinaryWrite((byte[])rdr["image"]);
  
            }
  </code></pre>
  
  <p>But still its not working</p>