GetSchema() returns error when SyncDirection is UploadOnly

I am in the process of running through the N-Tier example and have run into a problem. I have successfully run a test using Bi-Directional syncing through an asp.net webservice, however, when I try to test the UploadOnly Sync Dircection I receive the following error from the Web Service:

"Microsoft.Synchronization.Data.SchemaException: Unable to initialize the client database, because the schema for table 'Orders' could not be retrieved by the GetSchema() method of DbServerSyncProvider. Make sure that you can establish a connection to the client database and that either the SelectIncrementalInsertsCommand property or the SelectIncrementalUpdatesCommand property of the SyncAdapter is specified correctly. "

Here is the constructor of the WebService.

PublicSubNew()
_objServerProvider =
New DbServerSyncProvider()
Dim objBuilderAsNew SqlConnectionStringBuilder
'1. Prepare server db connection and attach it to the sync agent
objBuilder("Data Source") ="MyServer"
objBuilder("Integrated Security") =True
objBuilder("Initial Catalog") ="pub"

Dim objSQLConnectionAsNew SqlConnection(objBuilder.ConnectionString)
_objServerProvider.Connection = objSQLConnection

' 2. Create sync adapter for each sync table and attach it to the agent
Dim objOrdersBuilderAsNew SqlSyncAdapterBuilder
objOrdersBuilder.Connection = objSQLConnection
objOrdersBuilder.SyncDirection = SyncDirection.UploadOnly

objOrdersBuilder.TableName =
"orders"
objOrdersBuilder.DataColumns.Add("order_id")
objOrdersBuilder.DataColumns.Add(
"order_date")
objOrdersBuilder.TombstoneTableName ="orders_tombstone"
objOrdersBuilder.TombstoneDataColumns.Add("order_id")
objOrdersBuilder.TombstoneDataColumns.Add(
"order_date")
objOrdersBuilder.CreationTrackingColumn =
"create_timestamp"
objOrdersBuilder.UpdateTrackingColumn ="update_timestamp"
objOrdersBuilder.DeletionTrackingColumn ="update_timestamp"
objOrdersBuilder.UpdateOriginatorIdColumn ="update_originator_id"

Dim objSyncAdapterAs SyncAdapter = objOrdersBuilder.ToSyncAdapter
IfNot objSyncAdapter.SelectIncrementalInsertsCommandIsNothingThen

Dim objSQLParameterAs SqlParameter =CType(objSyncAdapter.SelectIncrementalInsertsCommand.Parameters("@sync_last_received_anchor"), SqlParameter)
objSQLParameter.DbType = DbType.Binary
objSyncAdapter.SelectIncrementalInsertsCommand.Parameters(
"@sync_last_received_anchor") = objSQLParameter


objSQLParameter = (
CType(objSyncAdapter.SelectIncrementalInsertsCommand.Parameters("@sync_new_received_anchor"), SqlParameter))objSQLParameter.DbType = DbType.Binary
objSyncAdapter.SelectIncrementalInsertsCommand.Parameters(
"@sync_new_received_anchor") = objSQLParameter
EndIf

_objServerProvider.SyncAdapters.Add(objSyncAdapter)

' select new anchor command
Dim objAnchorCmd =New SqlCommand
objAnchorCmd.CommandType = CommandType.Text
objAnchorCmd.CommandText =
"SELECT @@DBTS"
_objServerProvider.SelectNewAnchorCommand = objAnchorCmd

Dim objMappingCmdAsNew SqlCommand("SELECT 1", objSQLConnection)
objMappingCmd.CommandType = CommandType.Text
objMappingCmd.Parameters.Add(SyncSession.SyncClientId, SqlDbType.UniqueIdentifier)
_objServerProvider.SelectClientIdCommand = objMappingCmd
EndSub

Does anyone have any thoughts as to why this error is occuring?

[7078 byte] By [ChadQ] at [2008-2-19]
# 1


Hi

Try to set UploadOnly on the SyncTable object instead. When you set it on the SyncAdapterBuidler, the select incremental commands are not generated by the builder. These commands are used to get the table schema from the database. Since these are missing you are getting the schema error.

Thanks

RafikRobeal at 2007-9-7 > top of Msdn Tech,Visual Studio Orcas,Microsoft Synchronization Services for ADO.NET...

Visual Studio Orcas

Site Classified