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)