title: Retrieve PDF file stored in SQL Server database and then display on page
body: <p>I'm working on asp.net application where it display the retrieved pdf file from database on the page. I'm facing problem where the pdf file is not displaying in the page</p>
  
  <p>With this I'm attaching my code that I have tried:</p>
  
  <pre><code>        con.Open();
  
          SqlCommand cmd = new SqlCommand("select Pdf from SavePdf where IC='" + id +   
          "'", con);
          SqlDataReader dr = cmd.ExecuteReader();
  
          if (dr.Read())
          {
              byte[] fileData = (byte[])dr.GetValue(0);
  
              Response.Buffer = true;
              Response.Charset = "";
              Response.Cache.SetCacheability(HttpCacheability.NoCache);
              Response.ContentType = "application/pdf";
              Response.BinaryWrite(fileData);
              Response.Flush();
              Response.End();                   
          }
          dr.Close(); 
         }
  </code></pre>