Windows Service-based WCF

Source: Internet
Author: User

(1) Create a WCF code example: [Servicecontract]public interface Ilimsdbservice{[operationcontract]int ExecuteSQL (string strSQL);  [operationcontract]datatable getdatatable (String strsql);  [operationcontract]dataset GetDataSet (string strSQL);} public class Limsdbservice:ilimsdbservice{public int ExecuteSQL (string strsql) {oracledbhelper dbo = new Oracledbhelper ( CONFIGINFO.LIMSDBCONNSTR); return to dbo. ExecuteSQL (strSQL);}  public DataTable getdatatable (string strsql) {oracledbhelper dbo = new Oracledbhelper (CONFIGINFO.LIMSDBCONNSTR); Return to dbo. Getdatatable (strSQL);}  public DataSet GetDataSet (string strsql) {oracledbhelper dbo = new Oracledbhelper (CONFIGINFO.LIMSDBCONNSTR); Return to dbo. GetDataSet (strSQL);}} (2) Example of creating a Windows Service Code: Public partial class Limshssysservice:servicebase{servicehost limsdbservicehost = new ServiceHost ( typeof (Limsdbservice));p ublic Limshssysservice () {InitializeComponent ();} protected override void OnStart (string[] args) {Limsdbservicehost.open ();} protected override void OnstoP () {limsdbservicehost.close ();}} (3) Configuring the Client function code: Wshttpbinding binding = new Wshttpbinding (); EndpointAddress address = new EndpointAddress ("http://192.168.4.179:8732/Design_Time_Addresses/WcfLimsServer/ limsdbservice/"); Limsdbserviceclient lims = new Limsdbservice.limsdbserviceclient (binding, address); String sql = "Select sample_id, Material_type from Nais_all_samples where sample_id= "+ This.txtQuery.Text.Trim ();D atatable dt = LIMs. GetDataSet (SQL). Tables[0];this.gvdata.datasource = Dt;this.gvdata.databind ();

Windows Service-based WCF

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.