C#.net Creating a Web Services Instance-(DataSet)

Source: Internet
Author: User

1 usingSystem;2 usingsystem.web;3 usingSystem.Web.Services;4 usingSystem.Web.Services.Protocols;5 usingSystem.Data.OleDb;6 usingSystem.Data;7 usingSystem.IO;8 9 Ten[WebService (Namespace ="http://tempuri.org/")] One[WebServiceBinding (ConformsTo =wsiprofiles.basicprofile1_1)] A  Public classService:System.Web.Services.WebService - { -      PublicService () { the  -         //If you are using a design component, uncomment the following line -         //InitializeComponent (); -     } +  -     //[WebMethod] +     //Public string HelloWorld () { A     //return "Hello World"; at     //} -  - [WebMethod] -      PublicDataSet strSQL () -     {  -OleDbConnection con =NewOleDbConnection ("provider=microsoft.jet.oledb.4.0; Data Source=f:\\zjq\\webserver\\webs\\data.mdb"); inOleDbCommand cmd =NewOleDbCommand ("SELECT * from USESR", con); - con. Open (); toOleDbDataReader SDR =cmd. ExecuteReader (); +         // -DataTable table =NewDataTable ("table1"); theTable. Columns.Add ("uses"); *Table. Columns.Add ("PWS"); $         //Panax Notoginseng          while(SDR). Read ()) -         { theTable. Rows.Add (New string[2] {SDR. GetString (0), SDR. GetString (1) });  +         } A         // theDataSet DataSet =NewDataSet ("DataSet1"); + DataSet. Tables.add (table); -         returnDataSet; $     } $  -     // - [WebMethod] the      Public stringstrSQL2 () -     {WuyiOleDbConnection con =NewOleDbConnection ("provider=microsoft.jet.oledb.4.0; Data Source=f:\\zjq\\webserver\\webs\\data.mdb"); theOleDbCommand cmd =NewOleDbCommand ("SELECT * from USESR", con);  - con. Open (); WuOleDbDataReader SDR =cmd. ExecuteReader (); -         // AboutDataTable table =NewDataTable ("table1"); $Table. Columns.Add ("uses"); -Table. Columns.Add ("PWS"); -         // -          while(SDR). Read ()) A         { +Table. Rows.Add (New string[2] {SDR. GetString (0), SDR. GetString (1) }); the         } -         // $DataSet DataSet =NewDataSet ("DataSet1"); the DataSet. Tables.add (table); the         // theSystem.Text.StringBuilder Strbuilder =NewSystem.Text.StringBuilder (); theStringWriter writer =NewStringWriter (strbuilder); - DataSet. WRITEXML (writer, System.Data.XmlWriteMode.IgnoreSchema); in  the         returnStrbuilder. ToString (); the  About     } the      the}

C#.net Creating a Web Services Instance-(DataSet)

Related Article

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.