国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 中卫市| 溆浦县| 城口县| 九龙坡区| 泰安市| 和平区| 德惠市| 耿马| 海南省| 尖扎县| 馆陶县| 通江县| 和静县| 新晃| 砀山县| 潜山县| 凌源市| 乾安县| 伊宁县| 台州市| 泗洪县| 阿城市| 东城区| 梓潼县| 南通市| 华池县| 禹州市| 枣强县| 都江堰市| 隆化县| 石城县| 邵阳市| 永平县| 伊宁县| 山阳县| 陇南市| 松阳县| 孝感市| 古浪县| 武川县| 五莲县|