none
Error : "There is already an open DataReader associated with this Command " RRS feed

  • Question

  • hi every one!

    I'm programming sync application using MSF, An overview of the business that I have to implement is : a master table has some detail table ( dependency table), when implement MSF I was tracking on master table so when change enumeration (ChangesSelected event) i iterate row in per datatable in DataSet change then load dependency row from detail table to a Dictionary using same Transaction and Connection with Sync Framework current using to enumeration changes. when event SyncProgress I will download  dependency row (dependency row had cached on ChangesSelected  event)  of current row is processing from WCF server then apply to local database in same Transaction and Connection with Sync Framework current using to apply change.

    when call Synchronize from SyncOrchestator an exception throw on

    ERROR  , TestService, 7, 03/27/2013 18:25:03:296, RelationalSyncProvider.BatchedEnum: Caught exception while enumerating changes
    System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.
       at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command)
       at System.Data.SqlClient.SqlConnection.ValidateConnectionForExecute(String method, SqlCommand command)
       at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
       at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
       at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
       at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
       at Microsoft.Synchronization.Data.RelationalSyncProvider.EnumerateChangesInBatchesInternal(Object batchProducer)
    
    INFO   , TestService, 7, 03/27/2013 18:25:03:296,    RelationalSyncProvider.BatchedEnum: --- End Table "Orders" ---
    INFO   , TestService, 7, 03/27/2013 18:25:03:296, 
    VERBOSE, TestService, 7, 03/27/2013 18:25:03:296,       RelationalSyncProvider.BatchedEnum: Closing connection
    ERROR  , TestService, 7, 03/27/2013 18:25:03:296,       RelationalSyncProvider.BatchedEnum: Fatal exception in background thread. Details: System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.
       at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command)
       at System.Data.SqlClient.SqlInternalTransaction.Rollback()
       at System.Data.SqlClient.SqlInternalTransaction.Dispose(Boolean disposing)
       at System.Data.SqlClient.SqlTransaction.Dispose(Boolean disposing)
       at System.Data.Common.DbTransaction.Dispose()
       at Microsoft.Synchronization.Data.RelationalSyncProvider.EnumerateChangesInBatchesInternal(Object batchProducer)
    ERROR  , TestService, 7, 03/27/2013 18:25:03:328,       SyncBatchProducer: Background enumeration encountered an error.
    VERBOSE, TestService, 6, 03/27/2013 18:25:04:093, GetChanges called: MemoryDataCacheSize 10(Kb)

    i can't understand with it occur, i no using any datareader object any my class. Any one can help my solve this problem, plz?

    and i have addition a question : when expose Transaction on DbSelectingChangesEventArgs, DbChangesSelectedEventArgs  I can use this transaction to execute some action to sql server to load data, clean table, log ... because enumeration execute in separate thread so i not sure concurrently  programming in this case.

    Thansk all!

    sorry because my English, it's simple  word by word :(

     
    Wednesday, March 27, 2013 11:56 PM

Answers

  • So for reply late but i was found a temporarysolution in my case. I was modified connection string to enable multiply result set to TRUE.

    I used dependent table because it a legacy system ( no primary key, when user modified in application we delete all exists data relate then insert again to database)

    @JuneT  Thank so much for your reply

    Tuesday, April 30, 2013 6:47 PM

All replies

  • why cant you just add the dependent table as part of the sync scope?

    do you have concurrent syncs on going?

    Saturday, March 30, 2013 4:43 AM
    Moderator
  • So for reply late but i was found a temporarysolution in my case. I was modified connection string to enable multiply result set to TRUE.

    I used dependent table because it a legacy system ( no primary key, when user modified in application we delete all exists data relate then insert again to database)

    @JuneT  Thank so much for your reply

    Tuesday, April 30, 2013 6:47 PM