Invalid attempt to read when no data is present

7 posts, 0 answers
  1. Eric Krauska
    Eric Krauska avatar
    26 posts
    Member since:
    Dec 2007

    Posted 21 Dec 2010 Link to this post

    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)
  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 23 Dec 2010 Link to this post

    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.
  3. DevCraft banner
  4. Eric Krauska
    Eric Krauska avatar
    26 posts
    Member since:
    Dec 2007

    Posted 23 Dec 2010 Link to this post

    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.  
  5. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 27 Dec 2010 Link to this post

    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.
  6. Eric Krauska
    Eric Krauska avatar
    26 posts
    Member since:
    Dec 2007

    Posted 27 Dec 2010 Link to this post

    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?
  7. Serge
    Admin
    Serge avatar
    375 posts

    Posted 29 Dec 2010 Link to this post

    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.
  8. Eric Krauska
    Eric Krauska avatar
    26 posts
    Member since:
    Dec 2007

    Posted 04 Jan 2011 Link to this post

    That fixed it.  Thank you for the assistance!
Back to Top
DevCraft banner