我有一個SQL Server 2005框設置合併複製到SQL Server CE 3.0。出版物,出版商,分銷商和IIS都已經建立。SQL Server複製錯誤
在我的申請,我嘗試使用下面的代碼來同步數據庫:
//TODO: Change for production
//***************************
string localDBPath = @"C:\Documents and Settings\Robert\Desktop\MyDB.sdf";
//***************************
SqlCeReplication replicator = new SqlCeReplication();
replicator.InternetUrl = "http://myWebServer/sqlcesa30.dll";
replicator.Publisher = "mySqlServer";
replicator.PublisherDatabase = "myDatabase";
replicator.PublisherSecurityMode = SecurityType.NTAuthentication;
replicator.Publication = "myPublication";
replicator.Subscriber = Dns.GetHostName();
replicator.SubscriberConnectionString = @"Data Source=" + localDBPath;
try
{
// Check if the database file already exists
if (!System.IO.File.Exists(localDBPath))
{
// Add a new subscription and create the local database file
replicator.AddSubscription(AddOption.CreateDatabase);
}
// Transfer the initial snapshot of data if this is the first time this is called.
// Subsequent calls will transfer only the changes to the data.
replicator.Synchronize();
}
catch (SqlCeException ex)
{
// Display any errors in message box
MessageBox.Show(ex.Message);
}
finally
{
// Dispose of the SqlCeReplication object, but don't drop the subscription
replicator.Dispose();
}
不幸的是,該代碼將失敗,並出現以下錯誤消息「replicator.Synchronize」行:
未能通過提供的連接信息連接到SQL Server。 SQL Server不存在,訪問被拒絕,因爲IIS用戶不是SQL Server上的有效用戶,或者密碼不正確。
這個錯誤信息對我來說並不是很清楚,而且我沒有足夠的空間去尋找原因了。有任何想法嗎?