网上去收集的信息:用RDA把sql与sqlce数据同步问题

转载别人

  public void Pull(string localTableName, string sqlSelectString, string oleDBConnectionString, RdaTrackOption trackOption)
        {
            // Connection String to the SQL Server
            string rdaOleDbConnectString = "Provider=sqloledb;Data Source=10.102.197.20;Initial Catalog=Example;Integrated Security=False;User ID=sa;password=;";
            string localString = (@"Data Source =\My Documents\Example.sdf");
           
            SqlCeRemoteDataAccess rda = null;

            try
            {
                // Try the Pull Operation

                rda = new SqlCeRemoteDataAccess();
               // rda = new SqlCeRemoteDataAccess( "http://10.102.197.20/sqlce3/sqlcesa30.dll", localString);
                rda.InternetLogin = "";
                rda.InternetPassword = "";
              rda.InternetUrl = "http://10.102.197.20/sqlce3/sqlcesa30.dll";
                rda.LocalConnectionString = localString;

                rda.Pull("worktime1", "SELECT * FROM WorkTime where 1<>1", rdaOleDbConnectString, RdaTrackOption.TrackingOnWithIndexes, "ErrorTable");
                MessageBox.Show("ok");

            }
            catch (SqlCeException e)
            {
               MessageBox.Show(e.Message);
            }
            finally
            {
                rda.Dispose();
            }
        }

        //rda.push方法将 SQL Server CE 跟踪提取表中的更改传送回原始 SQL Server 表。
        public void Push(string localTableName, string oleDBConnectionString, RdaBatchOption batchOption)
        {
             string rdaOleDbConnectString = "Provider=SQLOLEDB; Data Source=10.102.197.20;Initial Catalog=Example;Integrated Security=False;User ID=sa;password=;";
             string localString = (@"Data Source =\My Documents\Example.sdf");

            // Initialize RDA Object

            SqlCeRemoteDataAccess rda = null;

            try
            {
                rda = new SqlCeRemoteDataAccess();
                rda.LocalConnectionString = localString;
                rda.InternetLogin = "MyLogin";
                rda.InternetPassword = " ";
                rda.InternetUrl = "http://10.102.197.20/sqlce3/sqlcesa30.dll";
                rda.LocalConnectionString = (@"Data Source =\My Documents\Example.sdf");


                rda.Push("WorkTime1", rdaOleDbConnectString, RdaBatchOption.BatchingOn);
                MessageBox.Show("success");
                // "insert into WorkTime1 select * from WorkTime  ",

            }
            catch (SqlCeException e)
            {
                MessageBox.Show(e.Message);
               // ShowErrors(e);
            }
            finally
            {
                rda.Dispose();
            }
        }




posted @ 2008-04-28 09:03  CODE  阅读(759)  评论(0编辑  收藏  举报