#眉標=Mobile、RDA、SQL CE #副標=Windows Mobile開發系列(17) #大標=用SQL Server CE同步行動裝置資料 #作者=文/圖 沈炳宏 ====================== 程式1 if (File.Exists ("\\Northwind.sdf") ) File.Delete ("\\Northwind.sdf"); SqlCeEngine engine = new SqlCeEngine ("Data Source = \\ Northwind;password=test;encrypt database=TRUE"); engine.CreateDatabase (); engine.Dispose(); ====================================== ====================================== 程式2 string rdaOleDbConnectString = "Provider=sqloledb; Data Source=localhost;Initial Catalog=test; User Id=sa;Password=sa"; SqlCeRemoteDataAccess rda = null; rda = new SqlCeRemoteDataAccess(); rda.InternetLogin = "login"; rda.InternetPassword = "pass"; rda.InternetUrl = "http://localhost/sqlce/sqlcesa35.dll"; rda.LocalConnectionString = @"Provider=Microsoft.SQLSERVER.OLEDB.CE.3.5; Data Source=\ Northwind.sdf"; rda.Pull( "runpc", "Select ●from runpc", rdaOleDbConnectString); rda = nothing; ====================================== ====================================== 程式3 SqlCeReplication myRep; myRep = new SqlCeReplication(); myRep.Publication = "RunPCData"; myRep.ExchangeType = ExchangeType.BiDirectional; try { myRep.AddSubscription( AddOption.ExistingDatabase); myRep.Validate = ValidateType.NoValidation; myRep.Synchronize(); } catch (SqlCeException ex) { try { } } ======================================