[Asp] ad wheel display code that can count the number of display times and set the number of display times

Source: Internet
Author: User

Based on the AC database, we have to update the display times of the database to the database every time. However, it turns out that a conflict error will be reported when the online traffic reaches 140. The background is rewritten to the following method and put into the application. Every n minutes or one of the banner is displayed and triggered to update the database. Practice has proved that the efficiency is greatly improved. Some Code that has been tested and tested in the past does not need to be used. Paste it slowly. Create a table using the code. And background.

Call bannerdisplay ()
Sub bannerdisplay ()
Dim arrbanner, arrlen, bannerdata, prvdbstate
Bannerdata = Application ("bannerdata ")
Arrlen = ubound (bannerdata)
If arrlen = 0 then
Response. Write "this ad space has no data"
Exit sub
Else
Dim B
Randomize
B = int (arrlen * RND ))
If bannerdata (B, 7) = false then
Response. Write "<a href = 'banenrgo. asp? Id = "& bannerdata (B, 0) &" 'target = '_ blank'> </a>"
Else
Response. Write (bannerdata (B, 6 ))
End if
If application ("bannerdata") (B, 5)-bannerdata (B, 4)> 1 then
If dbstate = false then
Dbopen ()
Prvdbstate = true
End if
Dim CS
Conn. execute ("Update [ad_banner] Set distimes =" & bannerdata (B, 5) + 1 & ", enddate = now, hasover = true where ADid =" & bannerdata (B, 0 ))
Set cs = server. Createobject ("zkxp. Cash ")
Set CS. Conn = Conn
Application. Lock ()
CS. loadbannerdata
Application. Unlock ()
Set cs = nothing
'Response. Write "<B> reload </B> <br>"
Else

Bannerdata (B, 5) = bannerdata (B, 5) + 1
Application. Lock ()
'Response. Write "<br> addoneid =" & bannerdata (B, 0) & "<br>"
'Response. write "display ap =" & Application ("bannerdata") (B, 5) & "arr =" & bannerdata (B, 5) & "<br>"
Application ("bannerdata") = bannerdata
'Response. Write "displayed after saving ap =" & Application ("bannerdata") (B, 5) & "<br>"
Application. Unlock ()
End if

If datediff ("N", application ("bannerdatasavedate"), now)> = sbdtdif then the variable sbdtdif is defined in userbin.
Application. Lock ()
Application ("bannerdatasavedate") = now
Application. Unlock ()
Dim I
If dbstate = false then
Dbopen ()
Prvdbstate = true
End if
For I = 0 to ubound (Application ("bannerdata")-1
Conn. execute ("Update [ad_banner] Set distimes =" & Application ("bannerdata") (I, 5) & "where ADid =" & Application ("bannerdata") (I, 0 ))
Next
End if

End if
If prvdbstate = true then dbclose ()
Bannerdata = NULL
End sub
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.