Answered by:
Error on Tutorial: Synchronizing SQL Server and SQL Express

Question
-
I've tried to follow Sync documentation version 2.1 SDK. But I've seen a lot of errors, my current error is "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."
This is my completed project: https://sites.google.com/site/tan351989/DemoSyncSQLserver_SQLserverExpress.rar?attredirects=0&d=1
Thanks for all!
static void Main(string[] args)
{
// create connection to the SQL Express database
SqlConnection clientConn = new SqlConnection(@"Data Source=.\SQLEXPRESS; Initial Catalog=SyncExpressDB; Trusted_Connection=Yes");
// create connection to the server database
SqlConnection serverConn = new SqlConnection("Data Source=localhost; Initial Catalog=SyncDB; Integrated Security=True");
// create the sync orhcestrator
SyncOrchestrator syncOrchestrator = new SyncOrchestrator();
// set local provider of orchestrator to a sync provider associated with the
// ProductsScope in the SyncExpressDB express client database
syncOrchestrator.LocalProvider = new SqlSyncProvider("ProductsScope", clientConn);
// set the remote provider of orchestrator to a server sync provider associated with
// the ProductsScope in the SyncDB server database
syncOrchestrator.RemoteProvider = new SqlSyncProvider("ProductsScope", serverConn);
// set the direction of sync session to Upload and Download
syncOrchestrator.Direction = SyncDirectionOrder.UploadAndDownload;
// subscribe for errors that occur when applying changes to the client
((SqlSyncProvider)syncOrchestrator.LocalProvider).ApplyChangeFailed += new EventHandler<DbApplyChangeFailedEventArgs>(Program_ApplyChangeFailed);
// execute the synchronization process =========== ERROR IS HERE ===========
SyncOperationStatistics syncStats = syncOrchestrator.Synchronize();
// print statistics
Console.WriteLine("Start Time: " + syncStats.SyncStartTime);
Console.WriteLine("Total Changes Uploaded: " + syncStats.UploadChangesTotal);
Console.WriteLine("Total Changes Downloaded: " + syncStats.DownloadChangesTotal);
Console.WriteLine("Complete Time: " + syncStats.SyncEndTime);
Console.WriteLine(String.Empty);
}
static void Program_ApplyChangeFailed(object sender, DbApplyChangeFailedEventArgs e)
{
// display conflict type
Console.WriteLine(e.Conflict.Type);
// display error message
Console.WriteLine(e.Error);
}
}Sunday, April 3, 2011 4:35 AM
Answers
-
well, if you changed the database connection then you'll get a different exception than the one you posted.
when you get the exception regarding the SelectNewTimeStampCommand, check the inner exception from there.
- Proposed as answer by jigu2014Microsoft employee, Editor Wednesday, April 6, 2011 4:48 PM
- Marked as answer by jigu2014Microsoft employee, Editor Monday, April 11, 2011 4:50 PM
Sunday, April 3, 2011 5:29 AM
All replies
-
have you checked what the inner exception says?
Sunday, April 3, 2011 4:52 AM -
I've checked inner exception by changing the name of database, server... and the error is different.
And I found SelectNewTimestampCommand { set; get; } is a member of Microsoft.Synchronization.Data.DbSyncProvider. But I don't know what can I do...
You can try with my project.
Inner exception:
Verify that you are connecting with valid credentials.
-
Make sure that the credentials you are supplying are valid. For more information, see How to: Access SQL Server Using Predetermined Credentials.
- Verify that the server name is correct and that the server is running.
-
Make sure that you are using the correct server name, and that the server can be reached. For more information, see How to: Create Connections to SQL Server Databases
This exception is thrown whenever the .NET Framework Data Provider for SQL Server encounters an error generated by the server.
Sunday, April 3, 2011 5:15 AM -
-
well, if you changed the database connection then you'll get a different exception than the one you posted.
when you get the exception regarding the SelectNewTimeStampCommand, check the inner exception from there.
- Proposed as answer by jigu2014Microsoft employee, Editor Wednesday, April 6, 2011 4:48 PM
- Marked as answer by jigu2014Microsoft employee, Editor Monday, April 11, 2011 4:50 PM
Sunday, April 3, 2011 5:29 AM -
i have check it too .....and i'm getting the same exception ....
i'm connectig between sqlserver and express database files...
does it need to activate any services else on the sqlserver
note:i'm using sqlserver2005
Wednesday, April 13, 2011 12:02 PM -
is it Sql Server 2005 SP2? minimum requirement for SQL Server 2005 is at least SP2
Wednesday, April 13, 2011 12:40 PM