This is some old code I came across a few days ago. I wrote it back in the late 90's its Classic ASP code to go to a Access database and randomly select a record that contains banner information and display it for the user to click on it.
<%@ Language=VBScript %>
<%
Response.Buffer=True
'Define our ADO constants
const adOpenStatic = 3
const adLockOptimistic = 3
'----- Create and Open Connection
Set MyConnection = Server.CreateObject("ADODB.Connection")
MyConnection.ConnectionString = "Banners"
MyConnection.Open
'----- Pick Ad from database
SQLBanners = "Select * from Banners"
Set Banners = Server.CreateObject("ADODB.Recordset")
Banners.CursorType = adOpenStatic
Banners.LockType = adLockOptimistic
Banners.Open SQLBanners, MyConnection
Randomize Timer
Banners.Move Int(RND * CInt(Banners.RecordCount))
'----- Increment Shown field value
Banners("Shown") = Banners("Shown") + 1
Banners.Update
'----- Create and display Response
ImageString = ""
ResponseString = "URL=" & Banners("URL")
ResponseString = ResponseString & "&BannerID=" & Banners("BannerID") & """>" & ImageString & ""
Response.Write ResponseString
Response.End
Response.End
'----- Clean up memory
Banners.Close
MyConnection.Close
Set Banners=Nothing
Set MyConnection=Nothing
%>
No comments:
Post a Comment