国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

c#編寫webservice服務(wù)引用實(shí)例分享

2020-01-24 02:59:29
字體:
供稿:網(wǎng)友

首先在新建了一個(gè)web服務(wù)文件。

復(fù)制代碼 代碼如下:

public  SqlWhhWebService1()
        {
            InitializeComponent();
        }
        #region Component Designer generated code

        //Required by the Web Services Designer
        private IContainer components = null;

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing && components != null)
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #endregion

然后自己調(diào)用自己的sqlhelper類中的方法,實(shí)現(xiàn)對(duì)數(shù)據(jù)的基本操作,其實(shí)和我們?cè)赽ll中的調(diào)用一樣,只不過通過[WebMethod]把自己所定義的方法暴露出來供外部調(diào)用,[WebMethod(Description="添加操作")]中的Description屬性標(biāo)注了對(duì)改方法的作用,同時(shí)在weiservice頁面中顯示出來。

復(fù)制代碼 代碼如下:

[WebMethod(Description="添加操作")]
        public ResultModel AddData(string sql, SqlParameter[] sp)
        {
            return WhhSqlHelper.Intersql(sql, sp);
        }
        /// <summary>
        /// 執(zhí)行更新操作
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="sp"></param>
        /// <returns></returns>
         [WebMethod(Description = "修改操作")]
        public ResultModel Updata(string sql,SqlParameter[] sp)
        {
            return WhhSqlHelper.UpdateSql(sql, sp);
        }
        [WebMethod(Description = "查詢操作")]
        public ResultModel selectSQL(string sql,SqlParameter[]sp)
        {
            return WhhSqlHelper.SingSelectSql(sql, sp);
        }
        [WebMethod(Description = "刪除操作")]
        public ResultModel Delete(string sql,SqlParameter[] sp)
        {
            return WhhSqlHelper.DeleteSql(sql,sp);
        }
        [WebMethod(Description = "是否存在操作")]
        public ResultModel IsExistent(string sql, SqlParameter[] sp)
        {
            return WhhSqlHelper.IsExistent(sql, sp);
        }

這些只是對(duì)基本的數(shù)據(jù)操作的web調(diào)用,還可以針對(duì)一些公共功能給提煉出來進(jìn)行web封裝,比如說,不同表的增刪改查,這些都可以的把封裝到一起。

其中的 WhhSqlHelper是我寫的一個(gè)sqlhelper類,ResultModel是我寫的一個(gè)數(shù)據(jù)操作的返回實(shí)體Model.

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 靖安县| 宝鸡市| 合肥市| 河南省| 沧州市| 明光市| 华容县| 富蕴县| 台北县| 武汉市| 家居| 芦山县| 温州市| 秦皇岛市| 甘孜| 四川省| 河东区| 海阳市| 万盛区| 灵武市| 错那县| 乡宁县| 通化市| 大宁县| 三原县| 林州市| 马山县| 冕宁县| 巩义市| 格尔木市| 罗山县| 肃北| 申扎县| 吴川市| 永春县| 三原县| 汝阳县| 麻城市| 东至县| 安泽县| 乡城县|