Data | Database This article introduces a new method of using ASP technology to realize database query in Flash, which not only hides the client completely. asp programs, and Flash's ease of use, graphics make your Web page unique.
Basic principle
1.Flash method of handling external variables
Flash uses the string specified by the URL in the frame properties as its own variable and its value, which can be either a CGI program or an ASP program, and the output string must be defined in the following format:
company=macromedia&address=600+townsend&
city=san+francisco&zip=94103
After the string is imported into flash, it is divided into 4 variables and given different values, namely:
This format is easy to implement using the Server.URLEncode method in ASP, and you can also implement it by programming:
<% @Language = "VBScript"% >
<%
Option Explicit
Dim var (3), I,count
I=0
Count=3
var (0) = "Red"
var (1) = "Yellow"
var (2) = "Blue"
Do While i< count
Response.Write "var" &i& "=" &var (i) & "&"
I=i+1
Loop
Response.Write "I=" &I
% >
The result of implementing this ASP program is:
Var0=red&var1=yellow&var2=blue&i=3
2. Transfer data between ASP and Flash
After your ASP program produces the string in the format above, you can use the action description of Load variables ("myscript.asp", 0) to pass it into Flash (Figure 1):
Of these, 0 means that the layer in which the animation is mounted is the first layer, 1 is the second layer, and so on.
Using the Load variables ("myscript.asp", 0,vars=post) Action description, ASP can use the following two methods to extract data from Flash:
1, Request.Form ("flash_var_1")
2. Request ("flash_var_1")
Using the Load variables ("myscript.asp", 0,vars=get) Action Description, ASP takes the data out of flash by means of:
Request.QueryString ("flash_var_1")
Example production
Let's take the telephone query as an example to make a Web page.
1. Create a database
Open Access 2000, create a database named Yjytelep.mdb, and design a table with the phone number of employees in this unit, the table name is YJYTELEP, the format is as follows:
Saves the table and database to the specified directory, such as C:\testasp\.
2. Create Web pages with Flash
① Open Flash 4 and create a phone query screen in frame 1, as shown in Figure 2. Right-click on the text edit box →properties→varible Enter the variable name NAMESTR; To prevent the animation from playing down, select "Stop" in frame 1→properties→action so that only if you enter a name and press the "Query" button, The animation will continue to play. On the Query button, right-click the mouse →properties→action description as:
On (release)
Go to and Play (2)
End on
② creates frame 2, which is a blank keyframe,action described as:
Load variables ("yjytelep.asp", 0, Vars=get)
③frame 3-8 creates an animation that tells the user that the ASP program is executing the query, as shown in Figure 3.
The action description for Frame 3 is:
If (Handnum ne "")
Go to and Stop (9)
End If
The action description for Frame 8 is:
Go to and Play (3)
This way, only the ASP program executes frame 9 when it queries all records and returns a full record.
④frame 9 is the resulting screen, as shown in Figure 4.
Under Name, create 5 text edit boxes whose variable names are name, Utelnum, Ptelnum, Callnum, Handnum. Create a "Back to check" button that describes the Action as:
On (release)
Go to and Stop (1)
End on
⑤ Save this Flash file in C:\testasp, the file name is: Yjytelep.fla. Then click File→publish to generate yjytelep.html and yjytelep.swf. To this, the flash work has been done, the next to write an ASP program.
3. Write ASP Program
Open Notepad, enter the following program and save it to C:\testasp, the file name is: yjytelep.asp.
<% @Language = "VBScript"% >
<%
Dim ORS, oconn
Set ORS = Server.CreateObject ("ADODB. Recordset ")
Set oconn= Server.CreateObject
("ADODB.") Connection ") oconn.connectionstring =
"Driver={microsoft Access Driver (*.mdb)};D bq=
"& Server.MapPath (" Yjytelep.mdb ")
oConn.Open
oRS.Open "SELECT * from Yjytelep", oconn, 2, 3
Ors.find "Name= '" "& Request.QueryString
("Namestr") & "'"
If ors.eof Then
Response.Write "Name= No this person &utelnum=-&ptelnum=
-&callnum=-&handnum=-"
Else
Response.Write "Name=" & Server.URLEncode (ORS
("Name")) & "&utelnum=" & Server.URLEncode
(ORS ("Utelnum")) & "&ptelnum=" & Server.URLEncode
(ORS ("Ptelnum")) & "&callnum=" & Server.URLEncode
(ORS ("Callnum")) & "&handnum=" & Server.URLEncode
(ORS ("Handnum"))
End If
Ors.close
Set ORS = Nothing
Oconn.close
Set oconn = Nothing
% >
4. Execute Query
Because the ASP program can only execute on the server side, be sure to start your PWS or IIS, and set the C:\testasp as a Web site, otherwise it will be an animation without results. All right, come on. Type http://localhost/testasp/yjytelep.html in your browser (localhost refers to the host domain name or IP address), and the results will be refreshing.