Invalid attempt to read when no data is present

From: Andy Sutorius (andy_at_sutorius.com)
Date: 02/24/05


Date: Thu, 24 Feb 2005 18:00:06 GMT

Hi,

I am getting the error "Invalid attempt to read when no data is present"
when I run the following code. I have checked the sql and it is returning
data. What am I missing?

   string sqlGetEmail = "SELECT content, subject FROM tblContent WHERE id =
" + Convert.ToInt16(ddlChooseEmail.SelectedValue.ToString());
   SqlCommand cmdGetEmail = new SqlCommand(sqlGetEmail, strConnString);
   SqlDataReader dtrEmail = cmdGetEmail.ExecuteReader();

   string strSubject = Convert.ToString(dtrEmail["subject"]);
   string strContent = Convert.ToString(dtrEmail["content"]);

   dtrEmail.Close();

Thanks,

Andy



Relevant Pages

  • Re: Oracle JDBC error
    ... I know there's no invalid names in the insert because I can insert ... I'm using oracle's ojbdc14 jdbc driver and Java 1.6. ... If so, post the SQL INSERT ... Oracle, when accessed via JDBC and similar libraries, processes the ...
    (comp.databases.oracle.server)
  • Re: Automating Access from Excel
    ... Thanks Andy! ... Actually I got my code running - it was a syntax thing. ... > This might be a help for getting data to and from Excel and Access: ... > includes examples of using variables in SQL queries. ...
    (microsoft.public.excel.programming)
  • RE: [Microsoft][SQLServer 2000 Driver for JDBC]The requested instance is either invalid or not runni
    ... instance is either invalid or not running. ... Produced By Microsoft MimeOLE V6.00.2800.1165 ... I can connect to it using SQL ... | [SQLServer 2000 Driver for JDBC]The requested instance is ...
    (microsoft.public.sqlserver.jdbcdriver)
  • Re: How do I temporarily limit values in a query field
    ... I am getting an error message: "The expression you entered has a invalid ..or! ... This is the last few lines of the 'old' sql with an attempt to limit the records to values of <500: ... works fine until I try to put limits on it value in the qryClaimDetails query. ...
    (microsoft.public.access.queries)
  • Re: Making dynamic table sortable
    ... The flip side of which results is websites filled with SQL injections ... Which is likely to be invalid SQL. ... error conditions. ... rather than the query ...
    (comp.lang.php)