Super Simple Flash+asp+access counter

Source: Internet
Author: User
access|asp+| counter

Although the counter does not have to use the database, but I this counter is really very very simple

Most of it was inspired by guoy_8186, and his voting tutorials were really good.

  Flash Code:

var count = new Loadvars (); Create a Loadvars object
Count.load ("Your Path/write.asp", count); Reading ASP files
Count.onload = function (success) {
if (success) {
visits = Count.total;
//above is to determine whether read completed, after the completion of the read to the variable assigned to the scene
}; ASP code:
<%
Dim rs
Dim sql
Dim conn ' Defines a variable
Set Rs=server.createobject ("Adodb.recordset") ' Create DataSet object
conn = "dbq=" + Server.MapPath ("Counter.mdb") + ";D efaultdir=;D river={microsoft Access DRIVER (*.mdb)};" ' Database connection statement, default is your space root directory, if the database file is preceded by a folder path to add to
Sql= "Update count set num=num+1 where id=1" ' Give num this value plus 1 statement
Rs.Open sql,conn,1,1 ' Execute write
Sql2= "SELECT * from Count where id=1" read statements
Rs.Open sql2,conn,1,1 ' perform read
If not rs.eof then
Total=rs ("num") ' assigns a value to a variable in the database
Response.Write "&total=" &total& "&" ' Write data in a form that flash can read
Else
End If
Set rs=nothing
Set conn=nothing
%>

Database with access, build a database called counter, in which a new table called count, the table only need to create two fields, a call ID, type automatic numbering, set as the primary key, another called num, the type is a number, this field is the place where the data is stored.

That's OK! Each time you open this Flash file will add 1 in the database, because read into the flash is a variable, you can handle it at will. Attached source code Download: Click here to download the source file



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.