.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Articles >> ASP.NET >> Post New Resource Bookmark and Share   

 Subscribe to Articles

AdRotator control with SQLServer

Posted By:ASPEvil       Posted Date: October 22, 2010    Points: 40    Category: ASP.NET    URL: http://www.dotnetspark.com  

Showing advertisements with AdRotator control from the SQLServer database

When you are building ASP.Net web pages then you have to face or already have faced the situation where you have to show some ads on the web pages. Generally all we do use AdRotator control for this purpose and create another xml file which contains the ads and the AdRotator control just reads those ads from the xml file and shows randomly.

But how it would be if we would be able to use our SQlServer database to store ads rather than the xml file and AdRotator control will read these ads from the SQLServer database and will show them as it does with xml? It would not be nice? Yes, and I did mention the steps to accomplish this, as below:-

1) Create a SQLServer table with the following columns and datatypes, as follow:-

Column Name            Data type                  Descrition
ID                     int                        Primary key. This column can have any name.

ImageUrl               nvarchar(length)           The relative or absolute URL of the image to
                                                  display for the ad.

NavigateUrl            nvarchar(length)           The target URL for the ad. If you do not provide
                                                  a value, the ad is not a hyperlink.

AlternateText          nvarchar(length)           The text displayed if the image cannot be found.
                                                  In some browsers, the text is displayed as a ToolTip.
                                                  Alternate text is also used for accessibility so that
                                                  users who cannot see the graphic can hear its description
                                                  read out loud.

Keyword                nvarchar(length)           A category for the ad on which the page can filter.

Impressions            int(4)                     A number that indicates the likelihood of how often
                                                  the ad is displayed. The larger the number, the more
                                                  often the ad will be displayed. The total of all
                                                  impressions values in the XML file may not exceed
                                                  2,048,000,000 - 1.

Width                  int(4)                     The width of the image in pixels.

Height                 int(4)                     The height of the image in pixels.

2)Drag and Drop an AdRotator control from the toolbox to the web page where you want to show the ads.

3)Click on the SmartTask window of the AdRotator control and select "New data source" under the "Choose Data Source"

4)Select "Database" from the "Data Source Configuration Wizard" and click the "Ok" button.

5)Now do the necessary actions with the "Configure Data Source" wizard to establish a successful connection with the table, you just did create in the Step1.

6)Now, finally run your application and see the AdRotator at work.
 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend