flex 访问数据库

flex调用vs2008部分

<fx:Declarations>
  <!-- 将非可视元素(例如服务、值对象)放在此处 -->
  <s:WebService id="sdf" wsdl="http://localhost:28919/WebSite1/Service.asmx?WSDL" result="sdf_resultHandler(event)">
   <s:operation name="sdfa"/>
  </s:WebService>
 </fx:Declarations>

<fx:Script>
  <![CDATA[

//操作函数,调用vs里面函数操作事件

protected function button1_clickHandler(event:MouseEvent):void
   {
    
    this.sdf.sdfa(sql);
   
    
   }

//结果处理函数

protected function sdf_resultHandler(event:ResultEvent):void
   {
    // TODO Auto-generated method stub
   
    this.txt.text =event.result.toString();
   
   }
   
  ]]>
 </fx:Script>

vs2008部分

新建webserveces 网站

using System; using System.Collections.Generic;

using System.Linq; using System.Web;

using System.Web.Services;

[WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。

// [System.Web.Script.Services.ScriptService]

public class Service : System.Web.Services.WebService {    

public Service ()

{

        //如果使用设计的组件,请取消注释以下行        

//InitializeComponent();  

   }

    [WebMethod]    

public string sdfa(string sql)    

{         return "Hello World";    

}    

}

posted @ 2013-08-14 20:50  空中飞车  阅读(372)  评论(0)    收藏  举报