You can store ad information in any type of database, as long as you have the corresponding data source control for that database.

### To create the database table for ads

1. If you do not already have a database table that contains the ad information, create a table with the following schema. All columns except ID are optional.
 Data types are provided as SQL Server types. If you are using a different database, substitute the appropriate corresponding type. Column name Data type Description 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. If you have an existing database table with ad information in it, set the following properties of the AdRotator control to map your database table schema to the fields required by the control:
3. Insert new records into the table with ad information.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddRotator.aspx.cs" Inherits="AddRotator" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<title>Untitled Page</title>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManger1" runat="Server">
</asp:ScriptManager>
<div>
<asp:Timer runat="server" Interval="10000" ID="SlideShowTimer" OnTick="SlideShowTimer_Tick" />
<asp:UpdatePanel runat="server" ID="SlideShow" UpdateMode="Conditional">
<ContentTemplate>
<asp:Image runat="Server" ID="SlideShowImage1" ImageUrl="" Width="100%" Height="150px" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="SlideShowTimer" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
<cc1:UpdatePanelAnimationExtender runat="server" ID="UPextender" TargetControlID="SlideShow"
BehaviorID="animation">
<Animations>
<OnUpdating>
<%-- It should take 1/2 of a second to fade out --%>
</OnUpdating>
<OnUpdated>
<%-- It should take 1 and 1/2 of a second to fade back in --%>
</OnUpdated>
</Animations>
</cc1:UpdatePanelAnimationExtender>
</div>
</form>
</body>
</html>

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class AddRotator : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{

}
}
protected void SlideShowTimer_Tick(object sender, EventArgs e)
{

}
{
DataTable dt = new DataTable();
SqlConnection con = new SqlConnection("Your Connection String");
da.Fill(dt);
return dt;
}
}

Reactions

1. Hi very good coding the only thing u forget is to update the updatepanel so that ads do change.

2. I am confused by the Image control. What is it's purpose?

3. Hi,

I was reading your article and I would like to appreciate you for making it very simple and understandable. This article gives me a basic idea of AdRotator Control in Asp.Net and it helped me a lot. Thanks for sharing with us. Check out this link too its also having nice post with wonderful explanation on AdRotator control....

Thank you very much for your precious post!!

Emoji
(y)
:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
x-)
(k)