none
Encountering error - "Invalid attempt to call FieldCount when reader is closed" in DataAdapter RRS feed

  • Question

  • Hi All:
    I encountered one strange problem. We called Enterprise Lib's code like this:
                        affectedRowCount =
                                _database.UpdateDataSet(dataRows, insertCommand, updateCommand, deleteCommand,
                                                        UpdateBehavior.Standard);

    Just set UpdateBatchSize of DataAdatper to 100. (We slightly adjusted the code of Enlib to expose the DataAdapter used in Update())


    But encountered the following exception:
    Type : System.InvalidOperationException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    Message : Invalid attempt to call FieldCount when reader is closed.
    Source : mscorlib
    Help link :
    Data : System.Collections.ListDictionaryInternal
    TargetSite : Void HandleReturnMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Messaging.IMessage)
    Stack Trace :
    Server stack trace:
       at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
       at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
       at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
       at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows)
       at Microsoft.Practices.EnterpriseLibrary.Data.Database.DoUpdateDataSet(UpdateBehavior behavior, DataRow[] dataRow, DbCommand insertCommand, DbCommand updateCommand, DbCommand deleteCommand)
       at Microsoft.Practices.EnterpriseLibrary.Data.Database.UpdateDataSet(DataRow[] dataRow, DbCommand insertCommand, DbCommand updateCommand, DbCommand deleteCommand, UpdateBehavior updateBehavior)
     

    It occurs at our user side. Actually we cannot simulate it. Does anyone has idea?

    Thanks and Regards
    Carol


    • Edited by Carol He Tuesday, February 7, 2012 3:57 AM
    Tuesday, August 25, 2009 2:32 AM

All replies

  • may be you will be calling performing a action on a closed data reader. check the code???? As i assume you are counting the affected number of rows. but you are using a closed data reader. Otherwise you haven't a active data reader to work with. Data reader Sample code : http://dileepsol.blogspot.com

    Tuesday, September 15, 2009 8:50 AM
  • Hi,

      I'm having the same problem. Have you found any solution yet?
    The problem is very hard to reproduce.

    thanks
    Tuesday, November 17, 2009 4:14 PM