Presentation is loading. Please wait.

Presentation is loading. Please wait.

SQL Server Mobile 2005 程序开发(四)

Similar presentations


Presentation on theme: "SQL Server Mobile 2005 程序开发(四)"— Presentation transcript:

1 SQL Server Mobile 2005 程序开发(四)
2019年1月13日12时30分 SQL Server Mobile 2005 程序开发(四) 黎 波 30分钟 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

2 内容 配置 Web 同步向导 远程数据访问(RDA) SqlCeRemoteDataAccess 的属性
2019年1月13日12时30分 内容 配置 Web 同步向导 远程数据访问(RDA) SqlCeRemoteDataAccess 的属性 SqlCeRemoteDataAccess 的方法 演示用 RDA 方式同步数据 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

3 目标 了解数据同步的部署环境 了解配置 Web 同步向导 掌握 SqlCeRemoteDataAccess 的基本使用
2019年1月13日12时30分 目标 了解数据同步的部署环境 了解配置 Web 同步向导 掌握 SqlCeRemoteDataAccess 的基本使用 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

4 为何需要数据同步?

5 2019年1月13日12时30分 数据同步的部署环境 Microsoft SQL Server 2005 Mobile Edition (SQL Server Mobile) 依靠客户端与服务器环境中的多个组件在设备和 Microsoft SQL Server 实例之间交换数据。 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

6 DEMO 演示:配置 Web 同步向导 2019年1月13日12时30分
演示通过编程方式创建、修复、压缩和收缩数据库,最后演示如何正确处理 SqlCeException。 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

7 2019年1月13日12时30分 远程数据访问(RDA) © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

8 SqlCeRemoteDataAccess 类

9 SqlCeRemoteDataAccess 常用属性
InternetUrl 指定在连接到 SQL Server Mobile Server Agent 时使用的 URL。SQL Server Mobile Server Agent 是将 SQL Server Mobile 客户端连接到 Microsoft SQL Server 数据库的 Microsoft 信息服务 (IIS) ISAPI DLL。必须指定此属性。 InternetLogin 和 InternetPassword 指定在连接到 SQL Server Mobile Server Agent 时使用的 Microsoft Internet 信息服务 (IIS) 登录名和密码。 InternetProxyLogin 和 InternetProxyPassword 指定在连接到需要进行身份验证的代理服务器)时使用的登录名。 InternetProxyServer 指定访问 InternetUrl 属性中指定的 HTTP 资源时使用的代理服务器。 LocalConnectionString 指定 SQL Server Mobile 数据库的连接字符串。

10 SqlCeRemoteDataAccess 其他属性
2019年1月13日12时30分 SqlCeRemoteDataAccess 其他属性 CompressionLevel 指定压缩例程在推送和提取操作期间将使用的压缩量。值 0 关闭所有压缩。默认值是 1,它占用的处理器时间最少,但仍能提供一些压缩。 ConnectionManager 启用 SqlCeRemoteDataAccess 对象以使用智能设备的连接管理器 API 来建立网络连接。同步结束时将释放连接。在需要代理设置时,如果设置了 InternetProxyServer、InternetProxyLogin 或 InternetProxyPassword 属性,则 SqlCeRemoteDataAccess 对象将不使用连接管理器代理设置。 CompressionLevel 指定压缩例程在推送和提取操作期间将使用的压缩量。使用 CompressionLevel 属性,您可以自定义压缩,以满足您的特定需要。如果值较低,压缩程序运行得就较快,但传输的数据没有进行紧密压缩,因此传输的时间较长。如果压缩级别值较高,则在运行 IIS 的服务器上将进行较多的处理,但可以减少数据传输时间。 数据压缩的实际量取决于所压缩的数据的类型。 值 0 关闭所有压缩。默认值是 1,它占用的处理器时间最少,但仍能提供一些压缩。 ConnectionManager 启用 SqlCeRemoteDataAccess 对象以使用智能设备的连接管理器 API 来建立网络连接。同步结束时将释放连接。 如果 ConnectionManager 属性设置为 true,则总是使用连接管理器建立连接。在需要代理设置时,除非设置了 RDA 对象的任何代理属性,否则将使用连接管理器的代理设置。如果设置了 InternetProxyServer、InternetProxyLogin 或 InternetProxyPassword 属性,则 SqlCeRemoteDataAccess 对象将不使用连接管理器代理设置。 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

11 SqlCeRemoteDataAccess 的方法
Pull Push SubmitSql

12 Pull 方法 // 从远程 SQL Server 数据库下载数据,并将这些数据存储在
// 本地 SQL Server Mobile 数据库的一个表中。 public void Pull ( string localTableName, //本地SQL Mobile表名 string sqlSelectString, //Select语句或存储过程 string oleDBConnectionString, //远程OLEDB数据连接字符串 RdaTrackOption trackOption, string errorTable ) trackOption 该选项指示 SQL Server Mobile 是否跟踪对提取的表所做的更改,以及提取的表上存在的索引是否转到具有主键约束的设备。 errorTable 一个本地错误表名称;以后在调用 Push 方法向 SQL Server 发送更改时,如果引发了错误,就会创建此本地错误表。

13 RdaTrackOption 枚举 TrackingOff 指示 SQL Server Mobile 不跟踪对所提取的表的更改。本地不创建任何 PRIMARY KEY 约束。 TrackingOffWithIndexes 指示 SQL Server Mobile 不跟踪对所提取的表的更改。在本地表上创建 sqlSelectString 中指定的 SQL Server 表上存在的索引和主键约束。 TrackingOn 指示 SQL Server Mobile 跟踪对所提取表的所有更改。本地表中将创建与为 sqlSelectString 指定的值相关的 PRIMARY KEY 约束。这是默认设置。 TrackingOnWithIndexes 指示 SQL Server Mobile 跟踪对所提取表的所有更改。在本地表上创建 sqlSelectString 中指定的 SQL Server 表上存在的索引和主键约束。

14 Pull 方法示例代码 // 实例化并配置 SqlCeRemoteDataAccess 对象
SqlCeRemoteDataAccess rda = new SqlCeRemoteDataAccess(); rda.InternetUrl = " rda.InternetLogin = "MyInternetLogin"; rda.InternetPassword = "<password>"; rda.LocalConnectionString = "Data Source=MyDatabase.sdf"; // 从 SQL Server 下载数据 rda.Pull( "Employees", "SELECT * FROM DimEmployee", "Provider=sqloledb;server=MySqlServer;database=AdventureWorks;uid=sa;pwd=;", RdaTrackOption.TrackingOnWithIndexes, "ErrorTable");

15 Push 方法 // 将 SQL Server Mobile 中跟踪的提取表中的更改传送回 // 原始 SQL Server 表。
public void Push ( string localTableName, string oleDBConnectionString, RdaBatchOption batchOption ) batchOption 此选项指示正发送回 SQL Server 表的更改是组成一批共用同一事务,还是分别应用。 BatchingOff 指示 SQL Server Mobile 对推入 SQL Server 的行不执行批处理。服务器分别处理每一行。这是默认设置。 BatchingOn 指示 SQL Server Mobile 将推入 SQL Server 中的所有行组成一批,归并到一个事务中。

16 SubmitSql 方法 // 提交将在远程服务器上 Microsoft SQL Server 中的数据库上 // 执行的 SQL 语句。
public void SubmitSql ( string sqlString, string oleDBConnectionString )

17 DEMO 演示:用 RDA 方式同步数据 2019年1月13日12时30分
演示通过编程方式创建、修复、压缩和收缩数据库,最后演示如何正确处理 SqlCeException。 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

18 小结 配置 Web 同步向导 远程数据访问(RDA) SqlCeRemoteDataAccess 的属性和方法
2019年1月13日12时30分 小结 配置 Web 同步向导 远程数据访问(RDA) SqlCeRemoteDataAccess 的属性和方法 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

19 2019年1月13日12时30分 Q & A © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

20 2019年1月13日12时30分 Thank You! © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

21 学习资源 SQL Server Mobile 2005 研究报告 SQL Server Mobile 联机丛书
2019年1月13日12时30分 学习资源 SQL Server Mobile 2005 研究报告 SQL Server Mobile 联机丛书 SQL Server 移动版产品概览 SQL Server 移动版特性 SQL Server 2005 Mobile Edition Datasheet 升级到 Microsoft SQL Server 移动版 MSDN Library © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.


Download ppt "SQL Server Mobile 2005 程序开发(四)"

Similar presentations


Ads by Google