title: No data is read in SqlReader Invalid attempt to read when no data is present.
body: <p>I know this problem has been posted millions of times before, but this might be different.</p>
  
  <p>I am using a sql table with columns id,year,month,pdffile</p>
  
  <p>in my webpage, I would like the user to view the pdf document that they would like to see from what time frame they choose.</p>
  
  <p>so far with this:</p>
  
  <pre><code>string year = ddlYear.SelectedValue.ToString();    
  string month = ddlMonth.SelectedValue.ToString();
  pdfFrame.Attributes["src"] = "../pdfDocs.ashx?Year=" + year + "&amp;Month=" + month;
  </code></pre>
  
  <p>it loads the pdf, if it is there. that is my problem.
  how would I catch the error in my question title? I want to catch that error and display a message in a label to the user saying that no file was found. I am using a handler to read the varbinary that is my pdf file.</p>
  
  <p>Here is the handler code:</p>
  
  <pre><code>SqlConnection conn = new SqlConnection(@"Server=DEV6\MSSQLHOSTING;Database=Intranet;Trusted_Connection=True;");
  conn.Open();
  SqlCommand cmd = new SqlCommand("select PDFDocument from LeaveChart where (Year like @Year and Month like @Month)", conn);
  cmd.Parameters.AddWithValue("Year", context.Request.QueryString["Year"]);
  cmd.Parameters.AddWithValue("Month", context.Request.QueryString["Month"]);
  SqlDataReader reader = cmd.ExecuteReader();
  
  reader.Read();
  
  byte[] content = (byte[])reader.GetValue(0);
  MemoryStream ms = new MemoryStream(content);
  ms.Position = 0;
  context.Response.ContentType = "Application/pdf";
  ms.WriteTo(context.Response.OutputStream);
  context.Response.End();
  reader.Close();
  conn.Close();
  </code></pre>
  
  <p>like I said, that works to display present files. can anyone offer some suggestions?
  is it possible to send a message from the handler back to the web page saying no file and how to display it without shocking the customer?</p>
  
  <p>thanks in advance</p>