Filtered Synchronization with SQL Azure and SQL CE3.5 using MS Sync Framework
I'm busy with a project to synchronize a SQL Azure and SQL CE 3.5 database. Each client has his\her's own CE database locally. When the client synchronizes with SQL Azure, only data relevant to the specific user needs to be synchronized. So I've created filter templates on the server for the table (only one at this point) that needs to be synchronized. I have specified all the Select, Update and Delete commands for the SyncAdapter, including the commands to retrieve the New and Max TimeStamps...
When I run the synchronization code I get the following error: "Failed to Execute Provider Command 'SelectNewTimestampCommand'. The transaction was rolled back. Ensure that the command syntax is correct and check the inner exception for any store-specific errors."
The Inner Exception looks like this: " InnerException: System.Data.SqlClient.SqlException Message=Incorrect syntax near '–'. Source=.Net SqlClient Data Provider ErrorCode=-2146232060 Class=15 LineNumber=1 Number=102 Procedure="" Server=tcp:lm5a34jqb2.database.windows.net State=1 StackTrace: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Microsoft.Synchronization.Data.DbSyncScopeHandler.GetLocalTimestamp(IDbConnection connection, IDbTransacti开发者_Python百科on transaction) InnerException: "
The error indicates: "Incorrect syntax near '-'" but that is just the command specified to retrieve the new TimeStamp. The code that created that command looks like this: "SqlCommand selectNewTimestampCommand = new SqlCommand(); string newTimestampVariable = "@" + DbSyncSession.SyncNewTimestamp;
selectNewTimestampCommand.CommandType = CommandType.Text;
selectNewTimestampCommand.Parameters.Add(newTimestampVariable, SqlDbType.Timestamp);
selectNewTimestampCommand.Parameters[newTimestampVariable].Direction = ParameterDirection.Output;
selectNewTimestampCommand.CommandText = "SELECT " + newTimestampVariable + " = ((min_active_rowversion()) – 1)";
mySyncProvider.SelectNewTimestampCommand = selectNewTimestampCommand;"
The only answer I seem to get on the internet, is that SP2 for SQL Server 2005 is not installed... Since I do not use SQL 2005, the solution is quite useless.
What could the problem be?
any particular reason why you're manually setting the adapters rather than having Sync Framework provision them for you?
have a look at the sample code here: How to: Configure and Execute Synchronization with SQL Azure and here: Extending SQL Azure data to SQL Compact using Sync Framework 2.1
精彩评论