AdRotator with Datasource

Posted on 2010-01-11
Medium Priority
Last Modified: 2012-05-08
I am using the ADRotator control with Datasource and I am getting the following error.

Exception Details: System.Web.HttpException: Only one of AdvertisementFile, DataSource, or DataSourceID properties can be set on AdRotator 'AdRotator1'.

Line 12:     Public Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Line 13:         AdRotator1.DataSource = FetchPicsFromDB()
Line 14:         AdRotator1.DataBind()
Line 15:     End Sub
Line 16:

The code below is what I have currently.  Can anyone help understand what the problem may be and how to solve it?  Side note I am using VWD 2010 & 4.0 .Net Framework, I don't know if this is causing a problem.

<form id="form1" runat="server">
        <div class="bannerdiv">
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="<%$ ConnectionStrings:IATDatabaseConnectionString %>" 
                SelectCommand="SELECT [ImgPath], [RedirectUrl], [AltText] FROM [PicBanner]"></asp:SqlDataSource>
            <asp:ScriptManager ID="ScriptManager1" runat="server"/>
            <asp:Timer ID="Timer1" Interval="2000" runat="server" />
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />

Code behind:   

 Public Category As String
    Dim rowsAffected As Integer
    Public dt As DataTable = New DataTable()
    Public Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        AdRotator1.DataSource = FetchPicsFromDB()
    End Sub

    Protected Function FetchPicsFromDB() As DataTable
        Dim myConnectionString As String
        Dim mQuery As String = "SELECT ImgPath, RedirectUrl, AltText FROM PicBanner"

        myConnectionString = "Data Source=Database Information"
        Dim da As New SqlDataAdapter(mQuery, myConnectionString)

        FetchPicsFromDB = dt
    End Function

    Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        AdRotator1.DataSource = FetchPicsFromDB()
    End Sub

Open in new window

Question by:Robert Treadwell
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
LVL 18

Accepted Solution

carlnorrbom earned 2000 total points
ID: 26286727

In your markup you have already declaratively specified a datasource:


Then you specify another datasource in the page_load, remove the declaratively specified datasource.


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question