<%@ 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 = "PROVIDER=SQLOLEDB;SERVER=YourServerName;UID=YourUID;" & _ "PWD=YourPWD;DATABASE=YourDATABASE" 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 = "<img src=""" & Banners("Image") & """ alt=""" & Banners("Hint") & """>" ResponseString = "<a href=""RedirectMe.asp?URL=" & Banners("URL") ResponseString = ResponseString & "&BannerID=" & Banners("BannerID") & """>" & ImageString & "</a>" Response.Write ResponseString Response.End '----- Clean up memory Banners.Close MyConnection.Close Set Banners=Nothing Set MyConnection=Nothing %>