469,963 Members | 1,692 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,963 developers. It's quick & easy.

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

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(Strin g 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()

----------------------------------------------------------------------------
----
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573
Nov 17 '05 #1
2 5035
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.

"Brent Burkart" <Br***********@wvmb.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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(Strin g 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()

-------------------------------------------------------------------------- -- ----
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573

Nov 17 '05 #2
myDataReader.Read() ' before Line 137
"Brent Burkart" <Br***********@wvmb.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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(Strin g 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()

-------------------------------------------------------------------------- -- ----
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by dazzalondon | last post: by
5 posts views Thread by KivanÁ Karaca | last post: by
2 posts views Thread by Cameron Frasnelly | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.