Environment: Adobe Flash cs4,vs2008, Access2003
implementation steps:
1, create ASP.net page testcommunicatewithflash.aspx, the contents of the inside of the page deleted, in the background to write code, to retrieve the database, generate a similar content, such as:
xqdbnum=15&xqdbfcnum=5&xqdbjrnum=5&xqdbxdnum=5&xqdbrzj=1250000&xqdbzrnum=2
This content is resolved to six variables in Flash, preceded by a variable name, followed by a value. Less gossip, directly on the code, this code is very simple, we can read, extract a pass over the parameters, extract the corresponding content, generate the above pass, output to the browser:
Copy Code code as follows:
protected void Page_Load (object sender, EventArgs e)
{
Object OID; User ID
if (! Page.IsPostBack)
{
Try
{
OID = request.params["ID"];
}
catch (Exception ex)
{
Response.Write (ex. message);
Return
}
OleDbConnection conn = new OleDbConnection ();
Conn. ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Persist Security Info=true;data source= "+ Server.MapPath (" ~/app_data/tdb_db.mdb ");
Conn. Open ();
OleDbCommand cmd = new OleDbCommand ();
Cmd. Connection = conn;
Executing specific SQL statements
Cmd.commandtext = "Select sum (xqdbnum), sum (xqdbfcnum), sum (xqdbjrnum), sum (xqdbxdnum), sum (XQDBRZJ), sum (xqdbzrnum) from Xqdb where Xqusername like ' "+ oid.tostring () +"% ";
OleDbDataReader reader = cmd. ExecuteReader ();
while (reader. Read ())
{
Response.Write ("xqdbnum=" + reader. GetValue (0) + "&xqdbfcnum=" + reader. GetValue (1) + "&xqdbjrnum=" + reader. GetValue (2) + "&xqdbxdnum=" + reader. GetValue (3) + "&xqdbrzj=" + reader. GetValue (4) + "&xqdbzrnum=" + reader. GetValue (5)); Reader. Close ();
Conn. Close ();
}
}
2, create a flash, I look at the online approach is to need to fix a few frames, one for sending, one for waiting for return, one for display. Since I test all show, then do not need so complex, only need to use dynamic text of the variable monitoring can be implemented, so I have only one frame, the name is arbitrary, but dynamic text variable settings and the same as the returned content (this is very important)
3. Create a button
4, in the action of the button to write code:
On (release) {
Trace ("http://www.jb51.net:1475/WebTest/TestCommunicateWithFlash.aspx?ID=" +it_uid.text);
Loadvariables ("http://www.jb51.net:1475/WebTest/TestCommunicateWithFlash.aspx?ID=" +it_uid.text, this, "POST");
}
5, Test, success
6, nonsense a sentence, if issued, need to pay attention to the Web site to change.
There are some details involved, we can check the relevant information on the Internet to see, has never been done before, got two hours to get it, a little sense of achievement