Home arrow ASP arrow Page 8 - Make Revenue With Your Own Banner Management System

Make Revenue With Your Own Banner Management System

In this article Mitchell shows us how to develop a simple ad campaign and management system using ASP and an SQL Server database.

Author Info:
By: Mitchell Harper
Rating: 5 stars5 stars5 stars5 stars5 stars / 33
November 01, 2001
  1. · Make Revenue With Your Own Banner Management System
  2. · Adding the banners
  3. · Saving the banners
  4. · The ASP to add the banner
  5. · The ASP to add the banner (contd)
  6. · Listing the banners
  7. · Deleting a banner
  8. · Displaying and tracking banners, impressions and click-thrus
  9. · The code in detail
  10. · Handling the banner clicks
  11. · Conclusion

print this article

Make Revenue With Your Own Banner Management System - Displaying and tracking banners, impressions and click-thrus
(Page 8 of 11 )

By now you should have created the four pages that I described in part one: addbanner1.asp, addbanner2.asp, banners.asp and delbanner.asp. You should save these pages in some sort of admin folder and use your Web server to configure the security permissions on this directory so that a username a password is required to access your banner scripts.

Having said that, I'll now demonstrate the code we'll use to retrieve a banner from our database, display it on our Web page and track both impressions and click-thrus for each banner.

Displaying a banner on your site:

No doubt you've been to thousands of Websites that display banners across the top of the screen. These could be 468x60 banners, 460x60, 215x125 etc. The point is that banners are the most popular form of advertising on the Internet.

To display a banner from the database on our site, four steps are required as pictured here:

Four steps to display a banner on your site

Create the following code and save it to a file called bannercode.asp

<%@ Language="VBScript" %>

<!-- METADATA Type="TypeLib" File="c:\program files\common files\system\ado\msado15.dll" -->


function GetBanner()

dim objConn

dim objComm

dim objRS

dim strBanner_VirtualPath

dim strBannerHTML

dim intNumBanners

dim intRandom

set objConn = Server.CreateObject("ADODB.Connection")

set objRS = Server.CreateObject("ADODB.Recordset")

strBanner_VirtualPath = "/banners/"

objConn.Open "Provider=SQLOLEDB; Data Source=localhost;Initial Catalog=myAdStuff; UId=sa; Pwd="

objRS.ActiveConnection = objConn

objRS.LockType = adLockReadOnly

objRS.CursorType = adUseForwardOnly

objRS.Open "select count(*) from banners"

intNumBanners = objRS.Fields(0).Value

if intNumBanners = 0 then

exit function

end if


intRandom = int(rnd(1)*intNumBanners)


objRS.Open "select * from banners"

objRS.Move intRandom

strBannerHTML = "<a href='bannerclick.asp?bannerId=" & objRS("bannerId") & "'><img border='0' src='" & strBanner_VirtualPath & objRS("bannerImage") & "'<>/a>"

Response.Write strBannerHTML

objConn.Execute "UPDATE banners SET bannerImpressions =bannerImpressions + 1 WHERE bannerId = " & objRS("bannerId")


set objConn = nothing

set objRS = nothing

end function


Now, let's break down the unfamiliar code...
blog comments powered by Disqus

- Central Scoreboard with Flash and ASP
- Calorie Counter Using WAP and ASP
- Creating PGP-Encrypted E-Mails Using ASP
- Be My Guest in ASP
- Session Replacement in ASP
- Securing ASP Data Access Credentials Using t...
- The Not So Ordinary Address Book
- Adding and Displaying Data Easily via ASP an...
- Sending Email From a Form in ASP
- Adding Member Services in ASP
- Removing Unconfirmed Members
- Trapping HTTP 500.100 - Internal Server Error
- So Many Rows, So Little Time! - Case Study
- XDO: An XML Engine Class for Classic ASP
- Credit Card Fraud Prevention Using ASP and C...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials