Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 16th, 2007, 06:34 AM
Authorized User
 
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP/SQL Problem

Hi,

I am designing a small advertisement management program in asp, and Sql Server 2000 as database.

My table has the following fields which are pretty self explanatory:


bannerId, bannertitle, bannerurl, imageURL, bannerpirority

bannerId = Autoincrement to generate unique id for a banner ad
bannertitle = String title of the banner
bannerurl = URL where the image is linked
imageURL = URL of the image file
bannerpirority = pirority of the banner to be displayed (1 = lowest, 5 = highest)


Now, I want to display the banner on a page based on its pirority, like if there are 3 banners A, B, C which have the pirority 1,2,3 respectively so banner C should be displayed more times as compared to banner B. Banner B should be displayed more times then banner A


Hope you got me, its like the more pirority a banner gets, the more its being displayed.


I am using the following SQl Query but I dnt think its the proper logic, can u plz help me?

Quote:
quote:select top 1 * from tbl_banner_management order by newid(), bannerpirority desc
Thanx in advance for your help.

-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
__________________
-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
 
Old February 16th, 2007, 12:47 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Testing is the best judge. How is it working now? Are you getting the results you want?

This may not be the best solution but I would just enter the banner into the tbl_banner as many times as I would like to increment the ratios and then just use the newid() function to select random records.

You can select DISTINCT from the table so that you only get one instance of a banner when editing.

Highest priority would insert 5 records or you could increase the ratios. If 5 is your highest priority then insert the record 25 times. If 1 is lowest and want that banner very infrequently, just INSERT once. I don't know what your table relationships are but you could always create a lookup table that INSERT's as many times as you want the priority level to be, a table that just holds the ID column value from tbl_banner and the ID from the lookup table:

BannerID LookupID
1 1
1 2
1 3
1 4
1 5
2 6
3 7
3 8

Then just select from the Lookup table using NEWID() an the ratios should match what you're looking for.

????
P

 
Old February 28th, 2007, 01:54 AM
Authorized User
 
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I have not yet received a satisfying reply so far :(

Ok lets tweak this a lil bit.

we can have a percentage based ad management system.

Like I have 3 banners in my database.

Banner A - To receive 50% Views
Banner B - To receive 30% Views
Banner C - To receive 20% Views

So suppose I refresh the page 10 times, I should get the following views of my banners

Banner A - 5 views
Banner B - 3 views
Banner C - 2 Views

Can u guys help me with this?


Thanx in advance

-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
 
Old February 28th, 2007, 09:17 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Use the adrotator, it should suit your needs perfectly.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old February 28th, 2007, 09:22 AM
Authorized User
 
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

with an ad rotator I cannot monitor how many views an ad has got.

Am I right?



-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
 
Old February 28th, 2007, 09:40 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

With out doing a little custom coding of your own, no.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old February 28th, 2007, 10:39 AM
Authorized User
 
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

can u plz guide me how to?

I am a newbie :)

-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
 
Old February 28th, 2007, 10:53 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I wont guide you step by step, but i will give you the general theory.

Read this post about the ad rotator: http://www.w3schools.com/asp/asp_adrotator.asp

as you can see you use:

response.write(adrotator.GetAdvertisement("ads.txt ")) to display a given ad to your page. Of course this does not allow you to track what is going on at all. Sooooo.

Write a function that acceptes adrotator.GetAdvertisement("ads.txt") as its argument, execute your business rules on which ad is being viewed (base on the argument that you have supplied) when you have completed your processing, simply return the value that was originally passed in.

so your final line may look like:
response.write(processAd(adrotator.GetAdvertisemen t("ads.txt")))

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old February 28th, 2007, 11:01 AM
Authorized User
 
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have no clue how to make that function :(a

-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
 
Old February 28th, 2007, 11:17 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Creating functions in asp:
http://www.4guysfromrolla.com/webtec...ner/faq5.shtml

instead of using response.write in the function you will want to return the value

function foo(param)

foo = param
end function

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Weird ASP/SQL Problem cancer10 Classic ASP Databases 4 March 7th, 2007 09:15 AM
SQL problem in ASP skwilliams Classic ASP Databases 0 December 19th, 2005 11:53 AM
Tricky asp/sql problem cedwards Dreamweaver (all versions) 8 June 13th, 2005 04:02 PM
Need help with ASP SQL Date problem bleutiger Classic ASP Professional 6 January 21st, 2005 12:41 AM
ASP SQL Date Problem Please help bleutiger Classic ASP Databases 5 January 20th, 2005 05:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.