Ajax+WCF+MySQL实现数据库部署并调用

打印 上一主题 下一主题

主题 546|帖子 546|积分 1638

​         最近的数据库课程要求将MySQL数据库部署在服务器上,参考了大佬们的博客后,总结一下。
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>先放上参考的大佬们的博客。
        【原创经验分享】JQuery(Ajax)调用WCF服务 <authentication mode="Forms"/>- <authentication mode="Forms"/>南宫萧尘 <authentication mode="Forms"/>- <authentication mode="Forms"/>博客园 <authentication mode="Forms"/>(cnblogs.com)
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>WinForm+WCF+mysql+http实现简单的用户登录注册_小瞄喵的博客-CSDN博客
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/> 未能加载文件或程序集“Renci.SshNet, <authentication mode="Forms"/>Version=2016.1.0.0, <authentication mode="Forms"/>Culture=neutral, <authentication mode="Forms"/>PublicKeyToken=……” <authentication mode="Forms"/>- <authentication mode="Forms"/>河耶悦子 <authentication mode="Forms"/>- <authentication mode="Forms"/>博客园 <authentication mode="Forms"/>(cnblogs.com)        
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>一、VS2019下载WCF组件
        进入到 C:\Program <authentication mode="Forms"/>Files <authentication mode="Forms"/>(x86)\Microsoft <authentication mode="Forms"/>Visual <authentication mode="Forms"/>Studio\Installer 文件夹下,打开 <authentication mode="Forms"/>vs_installer.exe。修改VS2019,点击单个组件,搜索WCF并下载安装。
​编辑
​编辑
 
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>二、 新建WCF项目
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>新建VS项目,选择WCF服务应用程序。将IService.cs、Service.svc删除(如果你不需要的话)。
​编辑
        添加新建项,选择WCF服务(支持Ajax)。
​编辑
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/> 三、配置Web.config参数
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>打开Web.config,配置Forms身份验证。
  1. <authentication mode="Forms"/>
复制代码
        ​编辑
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/> 右键单击 <authentication mode="Forms"/>Web.config,选择 <authentication mode="Forms"/>编辑WCF配置。
​编辑
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/> 右键单击 <authentication mode="Forms"/>绑定,新建绑定配置。
​编辑
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>选择 <authentication mode="Forms"/>webHttpBinding,修改 <authentication mode="Forms"/>配置-Name,将 <authentication mode="Forms"/>常规-CrossDomainScriptAcessEnabled <authentication mode="Forms"/>设为 <authentication mode="Forms"/>True。
        ​编辑
​编辑  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/> 点击 <authentication mode="Forms"/>服务-终结点,修改Name, <authentication mode="Forms"/>在 <authentication mode="Forms"/>BindingConfiguration处绑定之前的“绑定”。
​编辑
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>四、编写WCF服务
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>转到VS项目中之前创建的 <authentication mode="Forms"/>xxx.svc.cs文件中,添加如下两项。
  1. [JavascriptCallbackBehavior(UrlParameterName <authentication mode="Forms"/>="jsoncallback")]
复制代码
​编辑
  1. [WebGet <authentication mode="Forms"/>(ResponseFormat <authentication mode="Forms"/>=WebMessageFormat.Json)]
复制代码
​编辑  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/> 在 <authentication mode="Forms"/>[OperationContract] <authentication mode="Forms"/>下面编写函数。
  1. <authentication mode="Forms"/>public <authentication mode="Forms"/>string <authentication mode="Forms"/>First() <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>{ <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>return <authentication mode="Forms"/>"OK"; <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>} <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>[OperationContract] <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>[WebInvoke(Method <authentication mode="Forms"/>="GET",BodyStyle <authentication mode="Forms"/>=WebMessageBodyStyle.WrappedRequest, <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>ResponseFormat <authentication mode="Forms"/>= <authentication mode="Forms"/>WebMessageFormat.Json, <authentication mode="Forms"/>RequestFormat <authentication mode="Forms"/>= <authentication mode="Forms"/>WebMessageFormat.Json)] <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>/*有参数*/ <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>public <authentication mode="Forms"/>string <authentication mode="Forms"/>Second(string <authentication mode="Forms"/>name) <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>{ <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>string <authentication mode="Forms"/>msg <authentication mode="Forms"/>= <authentication mode="Forms"/>string.Format("{0}success",name); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>return <authentication mode="Forms"/>msg; <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>}
复制代码
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/> 现在,保存项目,右键 <authentication mode="Forms"/>svc文件,在浏览器中查看。
​编辑
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>出现如下网页,说明前面没啥问题。
​编辑  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/> 五、创建HTML,调用服务
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>新建一个HTML文件,其中,getJSON的URL链接为上图出现的。
  1. <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>
复制代码
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/> 点击按钮,均有alert弹窗出现。
​编辑
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/> 运行HTML文件没反应的,在同级目录下新建js文件夹,去网上下载 <authentication mode="Forms"/>jquery-1.8.3.min.js放进来。因为有一句 <authentication mode="Forms"/>src="js/jquery01.8.3-min.js"
        六、WCF连接MySQL
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>下载 <authentication mode="Forms"/>MySQL.Data.DLL(百度),右键项目-添加-引用,将下载的MySQL.Data.DLL加进去。
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>添加如下引用。
  1. using <authentication mode="Forms"/>MySql.Data;using <authentication mode="Forms"/>MySql.Data.MySqlClient;using <authentication mode="Forms"/>System.Data;
复制代码
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/> 配置MySQL,并创建连接。
  1. ​const <authentication mode="Forms"/>string <authentication mode="Forms"/>sqlconfig <authentication mode="Forms"/>= <authentication mode="Forms"/>"Server=localhost;Port=3306;Uid=root;Pwd=11111;Database=html1"; <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>MySqlConnection <authentication mode="Forms"/>connection <authentication mode="Forms"/>= <authentication mode="Forms"/>new <authentication mode="Forms"/>MySqlConnection(sqlconfig);
复制代码
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/> 编写相应函数,完整svc.cs代码如下。
  1. using <authentication mode="Forms"/>System;using <authentication mode="Forms"/>System.Collections.Generic;using <authentication mode="Forms"/>System.Linq;using <authentication mode="Forms"/>System.Runtime.Serialization;using <authentication mode="Forms"/>System.ServiceModel;using <authentication mode="Forms"/>System.ServiceModel.Activation;using <authentication mode="Forms"/>System.ServiceModel.Web;using <authentication mode="Forms"/>System.Text;using <authentication mode="Forms"/>MySql.Data;using <authentication mode="Forms"/>MySql.Data.MySqlClient;using <authentication mode="Forms"/>System.Data;namespace <authentication mode="Forms"/>databaseExport{ <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>[ServiceContract(Namespace <authentication mode="Forms"/>= <authentication mode="Forms"/>"")] <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>[AspNetCompatibilityRequirements(RequirementsMode <authentication mode="Forms"/>= <authentication mode="Forms"/>AspNetCompatibilityRequirementsMode.Allowed)] <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>[JavascriptCallbackBehavior(UrlParameterName <authentication mode="Forms"/>="jsoncallback")] <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>public <authentication mode="Forms"/>class <authentication mode="Forms"/>dataService <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>{ <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>// <authentication mode="Forms"/>格式转换:DataSet->JSON <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>public <authentication mode="Forms"/>string <authentication mode="Forms"/>DataTableToJSON(DataTable <authentication mode="Forms"/>dt) <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>{ <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>StringBuilder <authentication mode="Forms"/>jsonBuilder <authentication mode="Forms"/>= <authentication mode="Forms"/>new <authentication mode="Forms"/>StringBuilder(); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>jsonBuilder.Append("{"Name":"" <authentication mode="Forms"/>+ <authentication mode="Forms"/>dt.TableName <authentication mode="Forms"/>+ <authentication mode="Forms"/>"","Rows"); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>jsonBuilder.Append("":["); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>for <authentication mode="Forms"/>(int <authentication mode="Forms"/>i <authentication mode="Forms"/>= <authentication mode="Forms"/>0; <authentication mode="Forms"/>i <authentication mode="Forms"/>< <authentication mode="Forms"/>dt.Rows.Count; <authentication mode="Forms"/>i++) <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>{ <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>jsonBuilder.Append("{"); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>for <authentication mode="Forms"/>(int <authentication mode="Forms"/>j <authentication mode="Forms"/>= <authentication mode="Forms"/>0; <authentication mode="Forms"/>j <authentication mode="Forms"/>< <authentication mode="Forms"/>dt.Columns.Count; <authentication mode="Forms"/>j++) <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>{ <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>jsonBuilder.Append("""); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>jsonBuilder.Append(dt.Columns[j].ColumnName); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>jsonBuilder.Append("":""); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>jsonBuilder.Append(dt.Rows[i][j].ToString().Replace(""", <authentication mode="Forms"/>"\\"")); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>jsonBuilder.Append("","); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>} <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>jsonBuilder.Remove(jsonBuilder.Length <authentication mode="Forms"/>- <authentication mode="Forms"/>1, <authentication mode="Forms"/>1); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>jsonBuilder.Append("},"); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>} <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>jsonBuilder.Remove(jsonBuilder.Length <authentication mode="Forms"/>- <authentication mode="Forms"/>1, <authentication mode="Forms"/>1); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>jsonBuilder.Append("]"); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>jsonBuilder.Append("}"); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>return <authentication mode="Forms"/>jsonBuilder.ToString(); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>} <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>public <authentication mode="Forms"/>string <authentication mode="Forms"/>DataSetToJSON(DataSet <authentication mode="Forms"/>ds) <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>{ <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>StringBuilder <authentication mode="Forms"/>json <authentication mode="Forms"/>= <authentication mode="Forms"/>new <authentication mode="Forms"/>StringBuilder(); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>json.Append("{"Tables":"); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>json.Append("["); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>foreach <authentication mode="Forms"/>(System.Data.DataTable <authentication mode="Forms"/>dt <authentication mode="Forms"/>in <authentication mode="Forms"/>ds.Tables) <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>{ <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>json.Append(DataTableToJSON(dt)); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>json.Append(","); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>} <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>json.Remove(json.Length <authentication mode="Forms"/>- <authentication mode="Forms"/>1, <authentication mode="Forms"/>1); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>json.Append("]"); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>json.Append("}"); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>return <authentication mode="Forms"/>json.ToString(); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>} <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>// <authentication mode="Forms"/>在此处添加更多操作并使用 <authentication mode="Forms"/>[OperationContract] <authentication mode="Forms"/>标记它们 <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>[OperationContract] <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>[WebGet <authentication mode="Forms"/>(ResponseFormat <authentication mode="Forms"/>=WebMessageFormat.Json)] <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>/*无参数*/ <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>public <authentication mode="Forms"/>string <authentication mode="Forms"/>First() <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>{ <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>const <authentication mode="Forms"/>string <authentication mode="Forms"/>sqlconfig <authentication mode="Forms"/>= <authentication mode="Forms"/>"Server=localhost;Port=3306;Uid=root;Pwd=111111;Database=html1"; <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>MySqlConnection <authentication mode="Forms"/>connection <authentication mode="Forms"/>= <authentication mode="Forms"/>new <authentication mode="Forms"/>MySqlConnection(sqlconfig); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>connection.Open(); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>string <authentication mode="Forms"/>sql <authentication mode="Forms"/>= <authentication mode="Forms"/>"SELECT <authentication mode="Forms"/>* <authentication mode="Forms"/>FROM <authentication mode="Forms"/>test1"; <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>MySqlDataAdapter <authentication mode="Forms"/>adapter <authentication mode="Forms"/>= <authentication mode="Forms"/>new <authentication mode="Forms"/>MySqlDataAdapter(sql, <authentication mode="Forms"/>connection); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>DataSet <authentication mode="Forms"/>ds <authentication mode="Forms"/>= <authentication mode="Forms"/>new <authentication mode="Forms"/>DataSet(); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>adapter.Fill(ds); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>connection.Close(); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>return <authentication mode="Forms"/>DataSetToJSON(ds); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>} <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>[OperationContract] <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>[WebInvoke(Method <authentication mode="Forms"/>="GET",BodyStyle <authentication mode="Forms"/>=WebMessageBodyStyle.WrappedRequest, <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>ResponseFormat <authentication mode="Forms"/>= <authentication mode="Forms"/>WebMessageFormat.Json, <authentication mode="Forms"/>RequestFormat <authentication mode="Forms"/>= <authentication mode="Forms"/>WebMessageFormat.Json)] <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>/*有参数*/ <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>public <authentication mode="Forms"/>string <authentication mode="Forms"/>Second(string <authentication mode="Forms"/>name) <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>{ <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>string <authentication mode="Forms"/>msg <authentication mode="Forms"/>= <authentication mode="Forms"/>string.Format("{0}success",name); <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>return <authentication mode="Forms"/>msg; <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>} <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/> <authentication mode="Forms"/>}}
复制代码
 
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/> 点击 <authentication mode="Forms"/>工具-NuGet包管理器-程序包管理器控制台,运行如下命令,下载Renci.Ssh.NET.dll
  1. NuGet\Install-Package <authentication mode="Forms"/>SSH.NET <authentication mode="Forms"/>-Version <authentication mode="Forms"/>2016.1.0
复制代码
​编辑
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/> 跟前面一样,在浏览器中跑一下WCF服务,打开之前的HTML,点击 <authentication mode="Forms"/>无参数调用WCF测试 <authentication mode="Forms"/>,出现如下内容,说明已经读取到数据库中内容。
​编辑
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/> 七、部署IIS
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>打开控制面板-程序-启用或关闭Windows功能,勾选并确定。​编辑
 
 ​编辑
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/> 进入VS,右键项目,点击发布。选择方法为:文件系统,选择喜欢的目录,设置好后发布,如下图(该图引自WinForm+WCF+mysql+http实现简单的用户登录注册_小瞄喵的博客-CSDN博客
​编辑
 目录下会出现如下文件夹。
​编辑
         点击 <authentication mode="Forms"/>控制面板-系统和安全-管理工具,点击第一个 <authentication mode="Forms"/>IIS。
​编辑
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/> 右键单击 <authentication mode="Forms"/>网站,选择添加网站,确定网站名称,物理路径选择之前发布的目录。
​编辑
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/> 点击 <authentication mode="Forms"/>连接为,选择 <authentication mode="Forms"/>特定用户,输入你的电脑名称和登录密码。
​编辑
        如果出现如下情况,检查密码是否错误。如果密码没问题,给电脑新建一个用户,用新建的用户和密码连接。
​编辑
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>如果连接成功,点击测试设置,应该出现下图。
​编辑
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/> 选择IP地址和端口号,点击确定即可。浏览创建的网站,如下图。
​编辑
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/> 最后,将HTML文件中的URL地址改为该地址。如图。
​编辑
 
  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>  <authentication mode="Forms"/>OK,大功告成!

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

杀鸡焉用牛刀

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表