AdRotator Problem

Tech-Archive recommends: Fix windows errors by optimizing your registry



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(ConfigurationManager.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>
.