Detailed design of ASP graphic counter

Source: Internet
Author: User
Tags count
Counter | design | graphic | Here's a nice graphics counter designed without CGI.
Here is divided into three parts: 1, the establishment of graphics files.
2, establish the database.
3, write the code.
1, create graphics files.
First, use the graph software to make 10 graphs to display the count
10 digits of the device: 1,2,3,4,5,6,7,8,9,0. If
You have the art talent and you can make better graphics.
2, establish the database.
Use to create a database with the name. The database contains a table,
The first name is, the structure is: integer, there is a record, the initial value is 0.
Used to store the number of times the page was last accessed.
3, write the code.
—————— number.asp ————————————
<%@ language= "VBScript"%>
<!--#include file= "Adovbs.inc"-->
<%
Set Objconn=server.createobject ("Adodb.connection")
Objconn.attributes=adxactcommitretaining
Dbpath=server.mappath ("Num.mdb")
objConn.Open "Driver={microsoft Access Driver (*.mdb)};d bq=" & DBPath
Note: Establish a connection to the database.

sqlquery= "SELECT * from NUMT"
Set Rsrecordset=server.createobject ("Adodb.recordset")
Rsrecordset.open sqlquery,objconn,adopenkeyset,adlockoptimistic
Note: Open the database.

Application.Lock
Application ("NMB") =rsrecordset ("number")
Application.UnLock
Note: Assigns the last access count to the Application object

Application.Lock
Application ("NMB") =application ("NMB") +1
Application.UnLock
Rsrecordset ("number") =rsrecordset ("number") +1
Rsrecordset.update
Rsrecordset.close
Objconn.close
Set rsrecordset=nothing
Set objconn=nothing
Remarks: Closes the database, releasing the object

Dim nmb1
Dim str ()
Nmb1=application ("NMB")
ReDim Str (NMB1)
For I=1 to Len (NMB1)
STR (i) =mid (nmb1,i,1)
Note: Get the corresponding graphics file for each number

Select Case STR (i)
Case "0"
imgf= "0.gif"
Case "1"
imgf= "1.gif"
Case "2"
imgf= "2.gif"
Case "3"
imgf= "3.gif"
Case "4"
imgf= "4.gif"
Case "5"
imgf= "5.gif"
Case "6"
imgf= "6.gif"
Case "7"
imgf= "7.gif"
Case "8"
imgf= "8.gif"
Case "9"
imgf= "9.gif"
End Select
Note: Output graphics

Response.Write "Next
%>



Related Article

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.