www.pudn.com > DelphiCDSService2010.rar > Service1.asmx.cs, change:2009-12-25,size:2209b


using System; 
using System.Collections.Generic; 
using System.Web; 
using System.Web.Services; 
using System.Web.Services.Protocols; 
using System.Data; 
using System.Data.SqlClient; 
 
namespace DelphiCDSService 
{ 
    /// <summary> 
    /// Service1 的摘要说明 
    /// </summary> 
    [WebService(Namespace = "http://tempuri.org/")] 
    [WebServiceBinding(ConformsTo = WsiProfiles.None)] 
    [SoapRpcService(RoutingStyle = SoapServiceRoutingStyle.SoapAction)] 
    [System.ComponentModel.ToolboxItem(false)] 
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。 
    // [System.Web.Script.Services.ScriptService] 
    public class Service1 : System.Web.Services.WebService 
    { 
 
        [WebMethod] 
        public string HelloWorld() 
        { 
            return "Hello World"; 
        } 
 
        [WebMethod] 
        public string Buf_GetADONetToCDSXml(string ADbase, string ATable, string ASQL) 
        { 
            string connstring = DNDDSToCDS.Buf_BuieldDbsConnString(".", ADbase, "yappuser", "2511187"); 
            SqlConnection sqlconn = new SqlConnection(connstring); 
            SqlDataAdapter daTable = new SqlDataAdapter(ASQL, sqlconn); 
            DataSet ds = new DataSet(); 
            daTable.FillSchema(ds, SchemaType.Mapped, ATable); 
            daTable.Fill(ds, ATable); 
 
            string retv = DNDDSToCDS.ToClientDataSet(ds,ATable); 
            return retv; 
        } 
 
 
        [WebMethod] 
        public string Buf_PutCDSXmlToADONet(string ADbase, string ATable, string ADOData) 
        { 
            string connstring = DNDDSToCDS.Buf_BuieldDbsConnString(".", ADbase, "yappuser", "2511187"); 
            String lsSQL = "select * from " + ATable + " where 1=2"; 
            BuleSQLAccess SQLAccess = new BuleSQLAccess(); 
            DataSet ds = SQLAccess.Buf_GetDataSet(connstring, lsSQL, ATable); 
 
            if (DNDDSToCDS.ToDotNetDataSet(ADOData,ref ds)) 
            { 
                ds = SQLAccess.Buf_PutDataSet(ds, ATable); 
                return "ok"; 
            } 
            else 
            { 
                return "error"; 
            } 
        } 
 
    } 
}