[Flex] flex与asp.net数据交换

flex 代码:
  1. "1.0" encoding="utf-8"?>
  2. "http://www.adobe.com/2006/mxml" layout="absolute">
  3. "http://localhost:2016/Service/Service.asmx?wsdl" id="ws1">
  4. "sqlcheck" result="ResultHandler()" >
  5.     
  6.         {sqlstring.text}
  7.     
  8. "http://localhost:2016/Service/Service.asmx?wsdl" id="query">
  9.         "queryliuyan">
  10.                 
  11.                         
  12.                                 {nameInput.text,titleInput.text,contentInput.text}
  13.                         
  14.                 
  15.         
  16.     
  17.         import mx.rpc.events.ResultEvent;
  18.             [Bindable]
  19.             private var asd:XML;
  20.             private function ResultHandler():void{
  21.                 asd = new XML(ws1.sqlcheck.lastResult);
  22.                 datetest.dataProvider = asd.children();
  23.                 title1.text = asd..title[1];
  24.                 name1.text = asd..name[1];
  25.                 date1.text = asd..date[1];
  26.                 content1.text = asd..content[1];
  27.                
  28.             }
  29.     ]]>
  30.         "47" y="26" id="datetest">
  31.                 
  32.                         "主题" dataField="title"/>
  33.                         "作者" dataField="name"/>
  34.                         "日期" dataField="date"/>
  35.                         "内容" dataField="content"/>
  36.                 
  37.         
  38.         "sqlstring" x="226" y="428" text="select title,name,date,content from liuyan"/>
  39.         "466" y="25" label="查询" fontSize="12" click="ws1.sqlcheck.send();"/>
  40.         "529" y="95" text="Label" id="title1" fontSize="14"/>
  41.         "529" y="130" text="Label" id="name1" fontSize="14"/>
  42.         "529" y="167" text="Label" id="date1" fontSize="14"/>
  43.         "529" y="205" text="Label" id="content1" fontSize="14"/>
 net代码

  1. using System;
  2. using System.Web;
  3. using System.Web.Services;
  4. using System.Web.Services.Protocols;
  5. using System.Data.OleDb;
  6. using System.Collections;
  7. using System.Data;
  8. [WebService(Namespace = "http://tempuri.org/")]
  9. [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  10. public class Service : System.Web.Services.WebService
  11. {
  12.     public Service () {
  13.         //如果使用设计的组件,请取消注释以下行 
  14.         //InitializeComponent(); 
  15.     }
  16.     [WebMethod]//直接显示在datagrid中
  17.     public string sqlscan(string sql)
  18.     {
  19.         OleDbConnection connection = new OleDbConnection();
  20.         connection.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=";
  21.         connection.ConnectionString += Server.MapPath("user.mdb");
  22.         System.Data.OleDb.OleDbDataAdapter liuyan = new OleDbDataAdapter(sql, connection);
  23.         DataSet dataset1 = new DataSet("test");
  24.         liuyan.Fill(dataset1);
  25.         return dataset1.GetXml();
  26.     }
  27.     [WebMethod]//这个才是连接数据库并显示在label中
  28.     public string sqlcheck(string sql)
  29.     {
  30.         OleDbConnection connection = new OleDbConnection();
  31.         connection.ConnectionString = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=";
  32.         connection.ConnectionString += Server.MapPath("user.mdb");
  33.         System.Data.OleDb.OleDbDataAdapter tempAdapter = new OleDbDataAdapter(sql, connection);
  34.         DataSet dataset = new DataSet("temp");
  35.         tempAdapter.Fill(dataset);
  36.         return dataset.GetXml();
  37.     }
  38. }


你可能感兴趣的:(Flex,flex,asp.net,dataset,webservice,datagrid,date)