sql server ce 与PC机上sql server 2000同步的问题
在微软的网站上下了一个SQL Server 2000 Windows CE Edition 和 .NET Compact Framework的范例,里面有sql server ce 与PC机上sql server 2000同步的程序如下:
lconn.Close();
InitConnStr(); //Initialize local connection and connection string
//Create replication object and initialize it
SqlCeReplication sscerepl = new SqlCeReplication();
sscerepl.InternetUrl=URL.Text; //URL of the server agent
sscerepl.InternetPassword = ""; //credentials for the IIS directory where the server agent resides
sscerepl.InternetLogin ="";
sscerepl.Publisher=SQLServer.Text; //publisher
sscerepl.Publication = "pubs"; //name of the publication
sscerepl.PublisherDatabase = "pubs"; //name of the published DB
sscerepl.PublisherLogin = user.Text; //credentials for the DB/PAL (publication access list)on server
sscerepl.PublisherPassword =password.Text;
sscerepl.Subscriber = "SQLCE_Sample_PPC"; //name of the client device (optional)
sscerepl.SubscriberConnectionString = lconnstr; //conn string for the local SQLCE DB
try
{
//MsgBox parameters
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
MessageBoxIcon icon = MessageBoxIcon.Exclamation;
MessageBoxDefaultButton defbutt = MessageBoxDefaultButton.Button1;
DialogResult result;
//If DB exists either delete and download a fresh one
//or open the existing. Adding a subscription is only necessary, when the DB is not subscribed yet
if (CheckforDBFile(DBPath))
{
//If there is a local DB File, the user has the option to delete it and to create a new one
//or to connect to the exisiting database which is already a subscriber and does not need
//to be added to a subscription - just synchronize with it
result = MessageBox.Show("DB already exists, overwrite?", "DB exists!", buttons,icon,defbutt);
if (result==DialogResult.Yes)
{
//Create File object and delete the old DB file
File.Delete(DBPath);
//Add the subscription with the DBcreate Option
sscerepl.AddSubscription(AddOption.CreateDatabase);
}
}
else
{
//Add the subscription with the DBcreate Option
sscerepl.AddSubscription(AddOption.CreateDatabase);
}
//Download the subscribed data
sscerepl.Synchronize();
//Display changed rows and conflicts
MessageBox.Show( "Table authors synchronized!\n\n" + sscerepl.PublisherChanges+ " local changes\n" + sscerepl.PublisherConflicts + " conflicts","Synchronize sucessful",MessageBoxButtons.OK, MessageBoxIcon.Exclamation,MessageBoxDefaultButton.Button1);
//Display data on the tab
DisplaylocalData_Repl();
}
catch(SqlCeException sqle) //catch SQLCE errors
{
// Use the error handling routine ShowError.
ShowErrors(sqle);
}
catch (Exception ex) //catch normal errors
{
MessageBox.Show("Error: " + ex.ToString(),"Error");
}
finally
{
//Clean up, dispose the replication object
sscerepl.Dispose();
}
运行后出现<A call to SQL Server Reconciler failed.>错误.
在sql server 2000的企业管理器中的复制监视器中可以看到CE上的同步程序已经成功登录,但出现错误<进程未能将快照传送给订阅服务器。
(源: 合并复制提供程序 (代理程序); 错误代码: -2147201001)>
怎么做呢?
程序是vs 2003做的.
问题点数:100、回复次数:6Top
1 楼aawolf(羌狼)回复于 2005-08-31 10:16:26 得分 50
使用合并复制的话,需要在SQL 2000那边进行配置.
如果只是很简单的访问,不如使用RDA的方式.具体的代码可以去MSDN里查Remote Data Access.Top
2 楼small_wei(small)回复于 2005-09-01 00:32:10 得分 0
需要在SQL 2000那边进行配置.具体如何配置呢?
RDA我已经搞清楚,但客户要求要用这个啊Top
3 楼small_wei(small)回复于 2005-09-01 18:37:29 得分 0
UPTop
4 楼iintsy(Dandy)回复于 2005-09-01 22:05:33 得分 50
PC上的复制同步我做过,
看样子你必须在PC的sql server 2000上设置发布pubs数据库,很简单的,在企业管理器下,工具->复制-〉创建和管理发布
------------------------------------
努力学习xslt中...Top
5 楼small_wei(small)回复于 2005-09-01 22:58:55 得分 0
在企业管理器下,工具->复制-〉创建和管理发布
这个我做了
运行后出现<A call to SQL Server Reconciler failed.>错误.
在sql server 2000的企业管理器中的复制监视器中可以看到CE上的同步程序已经成功登录,但出现错误<进程未能将快照传送给订阅服务器。
(源: 合并复制提供程序 (代理程序); 错误代码: -2147201001)>
能不能给我看一下你的部份程序叫呢?Top
6 楼small_wei(small)回复于 2005-09-03 12:39:49 得分 0
upTop




