首先在新建了一個(gè)web服務(wù)文件。
        //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頁面中顯示出來。
這些只是對(duì)基本的數(shù)據(jù)操作的web調(diào)用,還可以針對(duì)一些公共功能給提煉出來進(jìn)行web封裝,比如說,不同表的增刪改查,這些都可以的把封裝到一起。
其中的 WhhSqlHelper是我寫的一個(gè)sqlhelper類,ResultModel是我寫的一個(gè)數(shù)據(jù)操作的返回實(shí)體Model.
新聞熱點(diǎn)
疑難解答
圖片精選