error in asp : invalid attempt to read when no data is present

  • Thread starter Thread starter Brent Burkart
  • Start date Start date
B

Brent Burkart

Below is the error I am receiving. I have checked SQL Profiler and it is
receiving the correct query which runs fine in Query Analyzer. Any ideas?
Server Error in '/lockinsheet' Application.
----------------------------------------------------------------------------
----

Invalid attempt to read when no data is present.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Invalid attempt to read
when no data is present.

Source Error:

Line 135: myDataReader = myCommand.ExecuteReader()
Line 136:
Line 137: LoanNo.Text = myDataReader.Item("LoanNo")
Line 138: LoanOfficer.Text = myDataReader.Item("LoanOfficer")
Line 139: SubBy.Text = myDataReader.Item("SubBy")

Source File: c:\inetpub\wwwroot\lockinsheet\Report.aspx.vb Line: 137

Stack Trace:

[InvalidOperationException: Invalid attempt to read when no data is
present.]
System.Data.SqlClient.SqlDataReader.PrepareRecord(Int32 i)
System.Data.SqlClient.SqlDataReader.GetValue(Int32 i)
System.Data.SqlClient.SqlDataReader.get_Item(String name)
lockinsheet.Report.displaydata() in
c:\inetpub\wwwroot\lockinsheet\Report.aspx.vb:137
lockinsheet.Report.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\lockinsheet\Report.aspx.vb:119
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
 
You have to call the Read method of the datareader before accessing the
fields of the first row. It will return True if a row was fetched, and False
otherwise.
 
Back
Top