sql server 2000与sql server ce2.0通过SqlCeRemoteDataA

 
我已经安装过sql server 2000和sql server ce2.0,接下来只是给这两个安装补丁,我安装的补丁是:Microsoft_sql2ksp4chs1.exe和sqlce20sql2ksp4.exe(也就是sql server ce server tools),确保两个补丁是一样的版本,这里两个都是sp4的。
(1)安装Microsoft_sql2ksp4chs1
要先装这个Microsoft_sql2ksp4chs1,他是sql server2000的很容易安装,按照步骤就好了。
(2)安装sqlce20sql2ksp4.exe
注意:在安装前,确保IIS服务已经启动
    i. 按照提示安装
    ii. 进入SQL Server CE Virtual Directory Creation Wizard界面
    iii. 给virtual directory 输入名称 “sscepubs”(这个你可以自己命名)
    iv. 选择“anonymous access”
    v. 下一步,不进行任何选择
    vi. 安装完成
(3)修改SQL Server 2000
    进入SQL Server的企业管理器,在正在运行的Sever中选择安全性,新建登陆,新增加用户IUSER_计算机名(Internet来宾帐号), 并在数据库访问中选中要访问的数据库,增加角色”db_owner”,点击确定,完成权限设置
    (4)测试是否安装成功
    在IE中输入http://服务器的IP地址/sscepubs/sscesa20.dll,  如果连接成功且出现“SQL Server CE Agent”
这样子就好了,可以利用SqlCeRemoteDataAccess这个来实现同步了
pull是从 SQL Server 数据库中提取数据并将其存储在 SQL Server CE 数据库的表中
// Connection String to the SQL Server.
        string rdaOleDbConnectString  = "Provider=sqloledb; Data Source=MySqlServer;Initial Catalog=Northwind; " +
                                        "User Id=username;Password = <password>";

        // Initialize RDA Object.
        SqlCeRemoteDataAccess rda = null;
        try {
            //Try the Pull Operation.
            rda = new SqlCeRemoteDataAccess();

            rda.InternetLogin          = "MyLogin";
            rda.InternetPassword       = "<password>";
            rda.InternetUrl            = "http://服务器的IP地址/sscepubs/sscesa20.dll";
            rda.LocalConnectionString  = @"Provider=Microsoft.SQLSERVER.OLEDB.CE.2.0;Data Source=\ssce.sdf";

            rda.Pull(
                "Employees",
                "Select * from Employees",
                rdaOleDbConnectString,
                RdaTrackOption.TrackingOnWithIndexes ,
                "ErrorTable");
        }
        catch(SqlCeException) {
            //Use you own Error Handling Routine.
        }
        finally {
            //Dispose of the RDA Object.
            rda.Dispose();
        }
push是将 SQL Server CE 数据库中跟踪提取表中的更改传送回 SQL Server 表
string rdaOleDbConnectString  = "Provider=sqloledb; Data Source=MySqlServer;Initial Catalog=Northwind; " +
            "User Id=username;Password = <password>";

        // Initialize RDA Object.
        SqlCeRemoteDataAccess rda = null;
        try {
            //Try the Pull Operation.
            rda = new SqlCeRemoteDataAccess();

            rda.InternetLogin          = "MyLogin";
            rda.InternetPassword       = "<password>";
            rda.InternetUrl            = "http://服务器的IP地址/sscepubs/sscesa20.dll";
            rda.LocalConnectionString  = @"Provider=Microsoft.SQLSERVER.OLEDB.CE.2.0;Data Source=\ssce.sdf";

            rda.Push("MyLocalTable",
                rdaOleDbConnectString,
                RdaBatchOption.BatchingOn);
        }
        catch(SqlCeException) {
            //Use you own Error Handling Routine.
        }
        finally {
            //Dispose of the RDA Object.
            rda.Dispose();
        }
刚接触pda开发,什么都不懂,一点点地摸索吧,谢谢我的同事!

(一)安装.NET CF和SQL CE组件
          netcf.core.ppc3.arm.cab
          System_SR_chs.cab
          sqlce.ppc3.arm.CAB
          sqlce.dev.ppc3.arm.CAB
          sql.ppc3.arm.CAB
posted @ 2008-11-25 18:13  googlegis  阅读(217)  评论(0编辑  收藏  举报

坐标合肥,非典型GIS开发人员 GitHub