2022年Silverlight访问数据库之MySQL数据库[参 .pdf
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《2022年Silverlight访问数据库之MySQL数据库[参 .pdf》由会员分享,可在线阅读,更多相关《2022年Silverlight访问数据库之MySQL数据库[参 .pdf(6页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、Silverlight访问数据库之 MySQL 数据库本文将为大家介绍如何让Silverlight 使用 MySQL 作为后台数据库以及CURD 操作。准备工作1)建立起测试项目细节详情请见 强大的 DataGrid 组件2_ 数据交互之 ADO.NET Entity Framework2)创建测试用数据库如下图所示,创建一个名为employees的 MySQL 数据库,建立数据表名称为Employee。3)安装 MySQL Connector Net 6.1.1 为了能让 .NET 操作 MySQL 数据库,请务必安装。【点击:下载地址 】建立数据模型EmployeeModel.cs文件(放
2、置在服务端项目文件夹下)using System; using System.Collections.Generic; using System.Linq; namespace dataformnmysqldb publicclassEmployeeModel publicint EmployeeID get ; set ; publicstring EmployeeName get ; set ; publicint EmployeeAge get ; set ; 建立服务端 Web Service 右击服务端项目文件夹,选择Add-New Item.,按下图所示建立一个名为Employee
3、sInfoWebService.asmx的 Web Service,作为 Silverlight 与 MySQL 数据库互操作的桥梁。名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 6 页 - - - - - - - - - 在 Silverlight 客户端应用程序文件夹下,右击References文件夹,添加名为MySql.Data 的命名空间。 之后,双击 EmployeesInfoWebService.asmx打开该文件,将里面的内容修改如下:using Syst
4、em; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using System.Data; using MySql.Data.MySqlClient;/ 引入该命名空间是为了操作MySQL 数据库namespace dataformnmysqldb / Summary description for EmployeesInfoWebService/ WebService(Namespace = http:/tempuri.org/) WebSer
5、viceBinding (ConformsTo = WsiProfiles.BasicProfile1_1) System.ComponentModel.ToolboxItem ( false ) / To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. / System.Web.Script.Services.ScriptService名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - -
6、- 名师精心整理 - - - - - - - 第 2 页,共 6 页 - - - - - - - - - publicclassEmployeesInfoWebService : System.Web.Services. WebService WebMethod / 获取雇员信息publicList GetEmployeesInfo() List returnedValue = newList (); MySqlCommand Cmd = new MySqlCommand(); SQLExcute(SELECT * FROM Employee , Cmd); MySqlDataAdapter
7、EmployeeAdapter = newMySqlDataAdapter (); EmployeeAdapter.SelectCommand = Cmd; DataSet EmployeeDataSet = new DataSet(); EmployeeAdapter.Fill(EmployeeDataSet); foreach ( DataRow dr in EmployeeDataSet.Tables0.Rows) EmployeeModel tmp = new EmployeeModel (); tmp.EmployeeID = Convert .ToInt32(dr0); tmp.E
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年Silverlight访问数据库之MySQL数据库参 2022 Silverlight 访问 数据库 MySQL
![提示](https://www.deliwenku.com/images/bang_tan.gif)
限制150内