This is a migrated thread and some comments may be shown as answers.

Invalid attempt to read when no data is present

6 Answers 272 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Eric Krauska
Top achievements
Rank 1
Eric Krauska asked on 21 Dec 2010, 09:26 PM
Running the latest version of ORM.  This error occurs on this version and the last version.  As you can see, it's a pretty simple query and we loop through each returned value and perform processing - all read access against the ORM.  We get the error after several hundred rows are read.  It varies from 200 rows to about 600 rows.  This tables has 2500 rows total in it.  Any ideas where to even begin to look?

using (sc.DAL.CommerceContext context = new DAL.CommerceContext())
{
    var address = (from c in context.Customers where ((c.OptedOut == null || c.OptedOut == false) && (c.Email != default(string))) orderby c.CustomerID select new { c.CustomerID, c.Email, c.OptedOut });                  
      
    foreach (var customer in address)
    

    

Telerik.OpenAccess.Exceptions.DataStoreException: System.InvalidOperationException: Invalid attempt to read when no data is present. at System.Data.SqlClient.SqlDataReader.ReadColumnHeader(Int32 i) at System.Data.SqlClient.SqlDataReader.IsDBNull(Int32 i) at OpenAccessRuntime.Data.VariableLengthStringConverter.Read(DataHolder& data) at OpenAccessRuntime.Relational.fetch.FopGetProjection.fetch(FetchResult fetchResult, StateContainer stateContainer) at OpenAccessRuntime.Relational.fetch.FetchSpec.createRow(FetchResult fetchResult, StateContainer stateContainer) Processing 1: [0] System.InvalidOperationException: Invalid attempt to read when no data is present. at System.Data.SqlClient.SqlDataReader.ReadColumnHeader(Int32 i) at System.Data.SqlClient.SqlDataReader.IsDBNull(Int32 i) at OpenAccessRuntime.Data.VariableLengthStringConverter.Read(DataHolder& data) at OpenAccessRuntime.Relational.fetch.FopGetProjection.fetch(FetchResult fetchResult, StateContainer stateContainer) at OpenAccessRuntime.Relational.fetch.FetchSpec.createRow(FetchResult fetchResult, StateContainer stateContainer) ---> System.InvalidOperationException: Invalid attempt to read when no data is present. at System.Data.SqlClient.SqlDataReader.ReadColumnHeader(Int32 i) at System.Data.SqlClient.SqlDataReader.IsDBNull(Int32 i) at OpenAccessRuntime.Data.VariableLengthStringConverter.Read(DataHolder& data) at OpenAccessRuntime.Relational.fetch.FopGetProjection.fetch(FetchResult fetchResult, StateContainer stateContainer) at OpenAccessRuntime.Relational.fetch.FetchSpec.createRow(FetchResult fetchResult, StateContainer stateContainer) --- End of inner exception stack trace --- at Telerik.OpenAccess.RT.ExceptionWrapper.Throw() at OpenAccessRuntime.storagemanager.logging.LoggingStorageManager.fetchNextQueryResult(ApplicationContext context, RunningQuery runningQuery, Int32 skipAmount) at OpenAccessRuntime.DataObjects.UnsynchronizedPMProxy.getNextQueryResult(QueryResultWrapper aQrs, Int32 skipAmount) at OpenAccessRuntime.DataObjects.ForwardQueryResult.getMoreData(Int32 requestedIndex) at OpenAccessRuntime.DataObjects.ForwardQueryResult.internalGet(Int32 requestedIndex) at OpenAccessRuntime.DataObjects.ForwardQueryResult.get_Item(Int32 indexParam) at Telerik.OpenAccess.RT.ListEnumerator.setCurrent(Int32 _pos) at Telerik.OpenAccess.RT.ListEnumerator.Move(Int32 relative) at Telerik.OpenAccess.Query.TypedEnumerator`1.System.Collections.IEnumerator.MoveNext() at sc.web.Admin.SendEmail._sendEmail_Click(Object sender, EventArgs e)

6 Answers, 1 is accepted

Sort by
0
PetarP
Telerik team
answered on 23 Dec 2010, 02:33 PM
Hi Eric Krauska,

 It is strange that your case initially works fine and then suddenly stops. Can you please share with us what backend are you using? Is it possible that you are using SQL Azure? Perhaps this can be a problem caused by the fact that your database server is a remote one.
We look forward to your reply.

All the best,
Petar
the Telerik team
Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
0
Eric Krauska
Top achievements
Rank 1
answered on 23 Dec 2010, 08:35 PM
SQL Server 2008 with all patches applied.  The application is a web app and SQL Server is installed on the same server as IIS (W2K3R2).  It's bizarre because I can't find any data that would cause this, nor is it consistent when running multiple times.  
0
Jan Blessenohl
Telerik team
answered on 27 Dec 2010, 11:41 AM
Hello Eric Krauska,
This looks weird to us, that the result set has no data any more after a while should not happen.

We have a background thread that closes connections if they are used for more than 2 minutes. This would happen if your read loop takes > 2 minutes. Can you check what you are doing in the foreach and if that can take such long?

Best wishes,
Jan Blessenohl
the Telerik team
Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
0
Eric Krauska
Top achievements
Rank 1
answered on 27 Dec 2010, 09:51 PM
that is definitely the issue.  For each iteration in the loop it is making a remoting call that takes approximately 1 second to complete - a total of about 30-40 minutes for this loop!  I'm sure we can rethink the logic and get rid of the for loop and use some async calls instead, but since this is a pretty quick application we'd prefer to keep it the way we have it if at all possible.  Any way to override the closing of the connection or adjust the timeout?
0
Serge
Telerik team
answered on 29 Dec 2010, 04:48 PM
Hello Eric Krauska,

 You can easily adjust all of the connection pool settings including the connection time out through the Model Settings Dialog. In it you will have to locate the Connection Pool tab under the Backend Settings tab and increase the timeout.

I hope this proves to be helpful. 

Kind regards,
Serge
the Telerik team
Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
0
Eric Krauska
Top achievements
Rank 1
answered on 04 Jan 2011, 07:17 PM
That fixed it.  Thank you for the assistance!
Tags
LINQ (LINQ specific questions)
Asked by
Eric Krauska
Top achievements
Rank 1
Answers by
PetarP
Telerik team
Eric Krauska
Top achievements
Rank 1
Jan Blessenohl
Telerik team
Serge
Telerik team
Share this question
or