我有一个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上的有效用户,或者密码不正确。
这个错误信息对我来说并不是很清楚,而且我没有足够的空间去寻找原因了。有任何想法吗?