CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  硬件/嵌入开发 >  嵌入开发(WinCE)

sql server ce 与PC机上sql server 2000同步的问题

楼主small_wei(small)2005-08-31 01:11:09 在 硬件/嵌入开发 / 嵌入开发(WinCE) 提问

在微软的网站上下了一个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

相关问题

  • WinCE上的SQL CE与PC进行差异同步的问题?
  • SQL CE的同步问题,能在模拟器中使用吗?
  • SQL server 2000同步
  • 急求:SQL同步问题
  • MS SQL Server 7 的数据同步
  • <在线>--关于两台SQL Sever 同步
  • 如何让Sql Server的两个Database的数据保持同步?
  • 真诚请教,sql server7数据同步问题?
  • 如何实现SQL Server的异地同步镜像!!!!
  • 救急啊!SQL Server 能不能异地同步更新数据!!!

关键词

  • sql server 2000
  • ce
  • 代码
  • sql
  • server
  • sscerepl
  • 同步
  • 复制
  • 程序
  • 错误

得分解答快速导航

  • 帖主:small_wei
  • aawolf
  • iintsy

相关链接

  • CSDN Blog
  • 技术文档
  • 代码下载
  • 第二书店
  • 读书频道

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo