title: How do I check a BLOB field has Data or not?
body: <p>I am working on <code>asp.net</code> with oracle database. I want to print the image of employee which is saved in an old table. I don't even the data type of image saved in the photo field of that table.</p>
  
  <p>I used Image handlers to print the images from newly created table but when I query on old tables the images is not getting printed.</p>
  
  <p><strong>How do I know that is there any image saved in the table?</strong></p>
  
  <p><strong>If there is an image why it's not getting printed?</strong></p>
  
  <p>I'll show you the code for image handler for both the table (NEW , OLD) Image from newly created table is printing very fine but what's the problem in old one.</p>
  
  <p>Can any give me any suggestions ?</p>
  
  <p>Here is my <code>ImgHandler.ashx</code> code ;</p>
  
  <pre><code> public void ProcessRequest (HttpContext context)
      {
          OracleDataReader rdr = null;
          OracleConnection conn = Conn.getConn();
          OracleCommand cmd = null;
          string ImgType = context.Request.QueryString["typ"].ToString();
          try
          {
              if (ImgType=="edu")//this is working fine
              {
                  cmd = new OracleCommand("select attachment pic from newtbl where lvldcp_code=" + context.Request.QueryString["dcp"] + "and emp_code="+context.Request.QueryString["emp"], conn);
              }
              else if (ImgType=="profile")
              {
                  cmd = new OracleCommand("select photo pic from oldtbl where emp_code="+context.Request.QueryString["emp"], conn);
              }
  
              conn.Open();
              rdr = cmd.ExecuteReader();
              while (rdr.Read())
              {
                  context.Response.ContentType = "image/jpg";
                  context.Response.BinaryWrite((byte[])rdr["pic"]);
              }
              if (rdr != null)
                  rdr.Close();
          }
          catch (Exception ex)
          {
  
          }
          finally
          {
              if (conn != null)
                  conn.Close();
          }
  
  
      }
  </code></pre>