By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,883 Members | 955 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,883 IT Pros & Developers. It's quick & easy.

AdRotator Problem

P: n/a
MC
I have coded an AdRotator to use a Database for it's data source. If I
use a SqlDataSource control it functions as expected, however if I
manually retreive the data using an OleDBDataReader It always omits the
first item in the result set? Code for each solution as below.

The reason I'm don't want to use the Declarative solution is that I
intend to Create a custom control that inherits from AdRotator and I
would then need to retrieve the Advert set programtically.

Regards
MC

------------------- Solution 1 - Declarative -------------------

<asp:Content ID="Content2" ContentPlaceHolderID="cphMainSite"
Runat="Server">
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:AdsDatabase %>"
ProviderName="<%$ ConnectionStrings:AdsDatabase.ProviderName %>"
SelectCommand="SELECT CompanyName AS ImageUrl, CompanyName AS
AlternateText, URL AS NavigateUrl, Impressions, Clicks FROM Sponsors
WHERE BannerAdvert=True" />
<asp:AdRotator ID="AdRotator1" runat="server"
DataSourceID="SqlDataSource1" />
</asp:Content>

------------------- Solution 2 - OleDBReader -------------------

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
using (System.Data.OleDb.OleDbConnection conn = new
System.Data.OleDb.OleDbConnection(ConfigurationMan ager.ConnectionStrings["AdsDatabase"].ConnectionString))
{
conn.Open();
using (System.Data.OleDb.OleDbCommand comm = new
System.Data.OleDb.OleDbCommand("SELECT CompanyName AS ImageUrl,
CompanyName AS AlternateText, URL AS NavigateUrl, Impressions, Clicks
FROM Sponsors WHERE BannerAdvert=True", conn))
{
AdRotator1.DataSource = comm.ExecuteReader();
AdRotator1.DataBind();
}
}
}
</script>
<asp:Content ID="Content2" ContentPlaceHolderID="cphMainSite"
Runat="Server">
<asp:AdRotator ID="AdRotator1" runat="server" />
</asp:Content>
Oct 6 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.