The advertising on my site is served entirely in-house, by code freely available for you to use. This article will step you through the code.
The banners are all stored in a database table, but I don't access the database to serve the ads. Instead, at the beginning of every day the site automatically loads the ads for that day into Application variables. How the "BrandNewDay" trigger works is discussed in a related article about tracking IP addresses.