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年5月6日2时40分 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 内容 数据库引擎的编程 查询分析器的使用 独有的数据访问对象 利用数据源快速创建应用程序 2019年5月6日2时40分
© 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

3 目标 掌握 SQL Mobile 数据库引擎的编程 掌握使用查询分析器的使用 了解 SQL Mobile 独有的数据访问对象
2019年5月6日2时40分 目标 掌握 SQL Mobile 数据库引擎的编程 掌握使用查询分析器的使用 了解 SQL Mobile 独有的数据访问对象 了解通过数据源快速创建应用程序的方法 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

4 数据库引擎的编程 SqlCeEngine 类 在 System.Data.SqlServerCe 命名空间下 创建数据库 验证和修复数据库
2019年5月6日2时40分 数据库引擎的编程 SqlCeEngine 类 在 System.Data.SqlServerCe 命名空间下 创建数据库 验证和修复数据库 压缩数据库 收缩数据库 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

5 2019年5月6日2时40分 创建数据库 // 创建数据库 File.Delete("Test.sdf"); SqlCeEngine engine = new SqlCeEngine(     "Data Source='Test.sdf'; LCID=1033; Password=1234; “ +"Encrypt=TRUE;"); engine.CreateDatabase(); © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

6 验证和修复数据库 // 验证和修复数据库 SqlCeEngine engine = new SqlCeEngine(
2019年5月6日2时40分 验证和修复数据库 // 验证和修复数据库 SqlCeEngine engine = new SqlCeEngine( "Data Source=AdventureWorks.sdf"); if (false == engine.Verify()) {     MessageBox.Show("Database is corrupted.");     engine.Repair(null, RepairOption.RecoverCorruptedRows); } © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

7 压缩数据库 通过从现有文件新建数据库文件来回收 SQL Server Mobile 数据库中浪费的空间。
2019年5月6日2时40分 压缩数据库 // 压缩数据库 SqlCeEngine engine = new SqlCeEngine( "Data Source=AdventureWorks.sdf"); //engine.Compact(null); 通过从现有文件新建数据库文件来回收 SQL Server Mobile 数据库中浪费的空间。 此方法还可用来更改数据库的排序顺序、加密或密码设置。 该连接字符串指定一个指向将由此方法创建的目标数据库的连接。 如果指定的数据库已经存在或者具有相同名称的另一文件已经存在,则会引发异常。 如果为连接字符串传递空字符串,则新的数据库文件将改写旧的数据库文件,但名称保持不变。 // 通过从现有文件新建数据库文件来回收 SQL Server Mobile 数据库中浪费的空间。 // 此方法还可用来更改数据库的排序顺序、加密或密码设置。 // 该连接字符串指定一个指向将由此方法创建的目标数据库的连接。 // 如果指定的数据库已经存在或者具有相同名称的另一文件已经存在,则会引发异常。 // 如果为连接字符串传递空字符串,则新的数据库文件将改写旧的数据库文件,但名称保持不变。 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

8 2019年5月6日2时40分 收缩数据库 // 收缩数据库 SqlCeEngine engine = new SqlCeEngine( "Data Source=AdventureWorks.sdf"); engine.Shrink(); 与 Compact 方法不同,Shrink 方法不创建临时数据库文件,将所有空页和未分配的页都移到了文件的结尾,然后截断,从而减小数据库的总大小。 // 通过将空页移动到文件的结尾然后截断该文件, // 来回收 SQL Server Mobile 数据库中浪费的空间。 // 与 Compact 方法不同,Shrink 方法不创建临时数据库文件, // 而是将所有空页和未分配的页都移到了文件的结尾,然后截断,从而减小数据库的总大小。 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

9 DEMO 演示:管理 SQL Mobile 数据库 2019年5月6日2时40分
演示通过编程方式创建、修复、压缩和收缩数据库,最后演示如何正确处理 SqlCeException。 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

10 2019年5月6日2时40分 查询分析器 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

11 2019年5月6日2时40分 演示:查询分析器 DEMO 打开Northwind.sdf数据库,简单操作一下,执行一条简单的SQL语句,并查看查询结果。 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

12 数据访问对象 System.Data.SqlServerCe 命名空间
2019年5月6日2时40分 数据访问对象 System.Data.SqlServerCe 命名空间 支持 ADO.NET 编程模型 SqlCeConnection、SqlCeTransaction、SqlCeCommand、 SqlCeCommandBuilder、 SqlCeDataAdapter、 SqlCeDataReader、DataSet、DataTable、DataView、SqlCeResultSet 和 ResultSetView 远程数据访问 SqlCeRemoteDataAccess 合并复制 SqlCeReplication © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

13 DEMO 演示:创建 SQL Mobile 程序 2019年5月6日2时40分 添加Northwind.sdf数据库的数据源
修改数据源为详细信息展现方式 修改某些控件类型 将数据源拖到窗体上 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

14 小结 SQL Mobile 数据库引擎的编程 使用查询分析器 SQL Mobile 独有的数据访问对象 通过数据源快速创建应用程序
2019年5月6日2时40分 小结 SQL Mobile 数据库引擎的编程 使用查询分析器 SQL Mobile 独有的数据访问对象 通过数据源快速创建应用程序 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

15 2019年5月6日2时40分 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.

16 学习资源 SQL Server Mobile 2005 研究报告 SQL Server Mobile 联机丛书
2019年5月6日2时40分 学习资源 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.

17 2019年5月6日2时40分 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.


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

Similar presentations


Ads by Google