浏览 3591 次
锁定老帖子 主题:flex与asp,access的联系(1)
该帖已经被评为新手帖
|
|
---|---|
作者 | 正文 |
发表时间:2007-08-24
conn.asp <% Dim Fy_Post,Fy_Get,Fy_In,Fy_Inf,Fy_Xh,Fy_db,Fy_dbstr '自定义需要过滤的字串,用 "|" 分隔 Fy_In = "'|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare|user" '---------------------------------- %> <% Fy_Inf = split(Fy_In,"|") '--------POST部份------------------ If Request.Form<>"" Then For Each Fy_Post In Request.Form For Fy_Xh=0 To Ubound(Fy_Inf) If Instr(LCase(Request.Form(Fy_Post)),"request")<>0 Then Response.Write "Please do not submit illegal parameters " Response.End End If Next Next End If '---------------------------------- '--------GET部份------------------- If Request.QueryString<>"" Then For Each Fy_Get In Request.QueryString For Fy_Xh=0 To Ubound(Fy_Inf) If Instr(LCase(Request.QueryString(Fy_Get)),Fy_Inf(Fy_Xh))<>0 Then Response.Write "Please do not submit illegal parameters " Response.End End If Next Next End If '---------------------------------- %> <% function getdata(sql,rs,conn) set conn=server.createobject("adodb.connection") db="book.mdb" conn.open "provider=Microsoft.Jet.OLEDB.4.0;Data Source="&server.mappath(db) set rs=server.createobject("adodb.recordset") rs.open sql,conn,3,2 end function function closedb(rs,conn) rs.close set rs=nothing conn.close set conn=nothing end function %> 然后就是建一个ASP文件去把数据库的内容读取并以XML形式显示. name2.asp <!--#include file="conn.asp"--> <% response.ContentType="text/xml" dim sql1,rs1,conn1 sql1="select * from book" getdata sql1,rs1,conn1 response.Write("<news>") do while not rs1.eof response.write("<item>") response.write("<id>"&rs1("id")&"</id>") response.write("<title>"&rs1("title")&"</title>") response.write("<ptime>"&rs1("ptime")&"</ptime>") response.write("<msg>"&rs1("msg")&"</msg>") response.write("<link>"&rs1("link")&"</link>") response.write("</item>") rs1.movenext() loop closedb rs1,conn1 response.write("</news>") %> 在IIS服务器下面测试通过之后,接着写一个MXML文件,去读取ASP得出的值. name2.mxml 文件 <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete = "feedRequest.send()"> <mx:HTTPService id="feedRequest" url="http://localhost/paragon/name2.asp" useProxy="false" contentType="application/xml" method="get" /> <mx:Panel x="10" y="10" width="475" height="400" layout="absolute"> <mx:DataGrid x="20" y="20" id="dgPosts" width="400" dataProvider="{feedRequest.lastResult.news.item}"> <mx:columns> <mx:DataGridColumn headerText="Column 1" dataField="title"/> <mx:DataGridColumn headerText="Column 2" dataField="ptime"/> <mx:DataGridColumn headerText="Column 2" dataField="msg"/> </mx:columns> </mx:DataGrid> <mx:LinkButton x="20" y="225" label="Read Full Post" click="navigateToURL(new URLRequest(dgPosts.selectedItem.link))"/> <mx:TextArea x="20" y="175" width="400"/> </mx:Panel> </mx:Application> 注意,我的ASP文件和数据库文件都放在paragon文件下面,然后我把mxml文件放在APACHE TOMCAT的webapps\flex目录下面,一切准备好之后,启动TOMCAT服务器,输入URL:http://localhost:8080/flex/name2.mxml 上面的前提是安装了FDS之后,并完成一些相关配置之后.具体配置可上网查阅. 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |