惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

AI
AI
TaoSecurity Blog
TaoSecurity Blog
H
Heimdal Security Blog
Help Net Security
Help Net Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
N
News | PayPal Newsroom
V2EX - 技术
V2EX - 技术
博客园 - 【当耐特】
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
Secure Thoughts
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy & Cybersecurity Law Blog
有赞技术团队
有赞技术团队
S
Schneier on Security
S
SegmentFault 最新的问题
Google Online Security Blog
Google Online Security Blog
H
Hacker News: Front Page
The Last Watchdog
The Last Watchdog
Schneier on Security
Schneier on Security
PCI Perspectives
PCI Perspectives
IT之家
IT之家
Project Zero
Project Zero
博客园 - 司徒正美
P
Privacy International News Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Jina AI
Jina AI
Security Latest
Security Latest
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
C
Check Point Blog
aimingoo的专栏
aimingoo的专栏
V
Vulnerabilities – Threatpost
W
WeLiveSecurity
NISL@THU
NISL@THU
Webroot Blog
Webroot Blog
N
Netflix TechBlog - Medium
L
Lohrmann on Cybersecurity

博客园 - aixia

好久不更新了 Flex图片过度增强版 Flex加载图片的常用的几种方式 - aixia - 博客园 组件Event新写法 - aixia - 博客园 遍历flex和flash对象的属性和方法 as3访问对象属性和方法的经典用法 - aixia - 博客园 一个蛮有用的event BitmapData中不明白的问题 Array为什么这样会有错? - aixia - 博客园 flex图片过度 AS3图片特效 自定义ToolTip flex采集证券数据 flash cs3 安装程序数据库损坏无法安装的解决方法 run-time debugger for adobe flex components flex使用外部参数详细版 给DateField和DateChooser进行汉化 flex module不编译的问题 自定义组件继承自定义组件
DataGrid通过webService和数据库绑定
aixia · 2007-11-27 · via 博客园 - aixia

webService   asp.net + access

数据库名db1

数据库表名test

字段名 test1  test2  test3  都是文本类型

随便输入一些数据

webService端测试代码

 1 OleDbConnection myConnection;
 2     OleDbDataAdapter myDataAdapter;
 3 
 4     public Service () {
 5 
 6         //Uncomment the following line if using designed components 
 7         //InitializeComponent(); 
 8       
 9         
10        
11         string dbname;
12         dbname=Server.MapPath("db1.mdb");
13         myConnection = new OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="+dbname );
14         myConnection.Open();
15 
16     }
17 
18     [WebMethod]
19     public string getInfo()
20     {
21         string sql = "SELECT * from test";
22         myDataAdapter = new OleDbDataAdapter(sql, myConnection);
23         
24        
25         DataSet ds = new DataSet();
26         ds.DataSetName = "testName";
27         myDataAdapter.Fill(ds, "test");
28 
29         return ds.GetXml();
30       
31     }
32 

flex端测试代码

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="Init()">
 3     <mx:WebService wsdl="http://127.0.0.1/web/Service.asmx?wsdl" useProxy="false" id="_webServer" >
 4         <mx:operation name="getInfo" result="OnGetInfoResult(event)">
 5             
 6         </mx:operation>
 7         
 8     </mx:WebService>
 9     
10     <mx:Script>
11         <![CDATA[
12             import mx.rpc.events.ResultEvent;
13             import mx.controls.Alert;
14             [Bindable]
15             private var _dataSource:XMLList;
16             
17             private function Init():void{
18                 _webServer.getInfo();
19             }
20             
21             private function OnGetInfoResult(e:ResultEvent):void{
22                 _dataSource = XML(e.result).children();
23             }
24         ]]>
25     </mx:Script>
26     <mx:DataGrid x="48" y="88" width="387" height="304" dataProvider="{_dataSource}">
27         <mx:columns>
28             <mx:DataGridColumn headerText="test 1" dataField="test1"/>
29             <mx:DataGridColumn headerText="test 2" dataField="test2"/>
30             <mx:DataGridColumn headerText="test 3" dataField="test3"/>
31         </mx:columns>
32     </mx:DataGrid>
33 </mx:Application>
34 

轻松搞定 flex 的dataGrid通过webService和数据库进行绑定

其中有一个设计理念就是  在不同的语言之间进行数据通讯的时候  设计的接口我提议使用标准的数据类型

至于到达表示端  如果不能满足表示端的需求 则只需要在表示端写适配器类