none
DBNull value can not be represented as a built-in .NET system type. Use SqlTypes or IsDBNull property.

    Question

  • Hi,

    A SQLNullValueException with the following message is thrown when I Synchronize a SqlCeSyncProvider with a SqlSyncProvider.

    The column at the specified ordinal (2) contains DBNull value which can not be represented as a built-in .NET system type. Use SqlTypes or IsDBNull property.

    If I populate the fields indicated by the ordinal value in the message (this is 1 based) then the message changes to indicate the next field that contains a null value.

       bei System.Data.SqlServerCe.SqlCeDataReader.GetInt64(Int32 ordinal)
       bei System.Data.SqlServerCe.SqlCeResultSet.GetInt64(Int32 ordinal)
       bei Microsoft.Synchronization.Data.SqlServerCe.SqlCeResultSetHandler.ReadMetadataForRow(SyncRowMetadata row, SqlCeCommitSequenceHelper csnHelper)
       bei Microsoft.Synchronization.Data.SqlServerCe.SqlCeChangeHandler.LocalVersionForRow(SyncRowMetadata row)
       bei Microsoft.Synchronization.Data.SqlServerCe.SqlCeChangeHandler.ApplyDelete(DbSyncBatchConsumer batchConsumer)
       bei Microsoft.Synchronization.Data.ChangeHandlerBase.ApplyChange(DbSyncBatchConsumer batchConsumer)
       bei Microsoft.Synchronization.Data.RelationalSyncProvider.ApplyChangesInternal(DbSyncScopeMetadata scopeMetadata, DataSet dataSet, ChangeApplicationType applyType)
       bei Microsoft.Synchronization.Data.RelationalSyncProvider.ApplyChanges(DbSyncScopeMetadata scopeMetadata, DataSet dataSet, DbSyncSession DbSyncSession, Boolean commitTransaction, String batchFileName, ChangeApplicationAction& action)
       bei Microsoft.Synchronization.Data.RelationalSyncProvider.ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, Object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics)
       bei Microsoft.Synchronization.KnowledgeProviderProxy.ProcessChangeBatch(CONFLICT_RESOLUTION_POLICY resolutionPolicy, ISyncChangeBatch pSourceChangeManager, Object pUnkDataRetriever, ISyncCallback pCallback, _SYNC_SESSION_STATISTICS& pSyncSessionStatistics)
       bei Microsoft.Synchronization.CoreInterop.ISyncSession.Start(CONFLICT_RESOLUTION_POLICY resolutionPolicy, _SYNC_SESSION_STATISTICS& pSyncSessionStatistics)
       bei Microsoft.Synchronization.KnowledgeSyncOrchestrator.DoOneWaySyncHelper(SyncIdFormatGroup sourceIdFormats, SyncIdFormatGroup destinationIdFormats, KnowledgeSyncProviderConfiguration destinationConfiguration, SyncCallbacks DestinationCallbacks, ISyncProvider sourceProxy, ISyncProvider destinationProxy, ChangeDataAdapter callbackChangeDataAdapter, SyncDataConverter conflictDataConverter, Int32& changesApplied, Int32& changesFailed)
       bei Microsoft.Synchronization.KnowledgeSyncOrchestrator.DoOneWayKnowledgeSync(SyncDataConverter sourceConverter, SyncDataConverter destinationConverter, SyncProvider sourceProvider, SyncProvider destinationProvider, Int32& changesApplied, Int32& changesFailed)
       bei Microsoft.Synchronization.KnowledgeSyncOrchestrator.Synchronize()
       bei Microsoft.Synchronization.SyncOrchestrator.Synchronize()
       bei MunroSoft.PatchSpy.Sync.Program.Synchronize() in D:\Projects\Munro.BananaRfid\MunroSoft.PatchSpy.Sync\Program.cs:Zeile 193.

    I would have expected null values to be handled correctly by default. Is there a resolution for this issue?

    Cheers,

    Scott


    MCSD.Net
    Wednesday, December 16, 2009 10:39 PM

Answers

  • Scott,

    It is supported with one catch: you need to dummy update the data in order to get the change tracking layer on CE to assign versions to everything.  One which way to do this would be to issue an update statement that simply assigns the PK values to themselves.  The reason you are seeing this exception is because the versions are currently NULL as the data was pre-existing in the database when tracking was enabled. 

    Hope that helps,
    Phil
    Thursday, December 17, 2009 11:15 PM
    Answerer

All replies

  • Scott-

    Could you provide more information about your scenario?  How was your CE database created?  Did you create it by pulling data from the SQL Server or was the data in the CE database pre-existing?

    Thanks,
    Phil
    Thursday, December 17, 2009 6:03 PM
    Answerer
  • Hi Phil,

    There was data in the CE database when I provisioned it. That you posed this question would tend to suggest that this is not supported. Could you confirm this please?

    Cheers,

    Scott
    MCSD.Net
    Thursday, December 17, 2009 10:30 PM
  • Scott,

    It is supported with one catch: you need to dummy update the data in order to get the change tracking layer on CE to assign versions to everything.  One which way to do this would be to issue an update statement that simply assigns the PK values to themselves.  The reason you are seeing this exception is because the versions are currently NULL as the data was pre-existing in the database when tracking was enabled. 

    Hope that helps,
    Phil
    Thursday, December 17, 2009 11:15 PM
    Answerer
  • Hi Phil,

    Yes that does help - thanks!

    Out of interest, do you think that this will be handled in future versions of the framework? A more informative exception or the version being set during provisioning would both be improvements.

    Cheers,

    Scott
    MCSD
    Sunday, December 27, 2009 9:24 PM
  • Scott,

    We are looking at features for the next version and making this easier is on the list.

    Thanks-
    Phil 
    Tuesday, January 05, 2010 5:48 PM
    Answerer