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

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()
 
M

Marina

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top