Click here to Skip to main content
15,847,903 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
how to display ads using mysql database in ad-rotator in vb.net . I am using data reader but , it only show one ad , no changing , also used data set with data adapter ,but error . Waiting For Solution.....

code:
VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       
         
        ad()

    End Sub


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


VB
Public Sub ad()

        cn.ConnectionString = "server=localhost; user id=root; password=; database=dc"
        cn.Open()
        s = "select * from ad"
        cd = New MySqlCommand(s, cn)
        'da.SelectCommand = cd
        'da.Fill(dt)
        r = cd.ExecuteReader()
        r.Read()

        AdRotator1.DataSource = r
        AdRotator1.ImageUrlField = "ImageUrl"
        AdRotator1.NavigateUrlField = "NavigateUrl"
        AdRotator1.AlternateTextField = "AlternateText"
        AdRotator1.DataBind()
        cn.Close()


    End Sub


On Page:


<asp:ScriptManager ID="ScriptManager1" runat="server">

<asp:Timer ID="Timer1" runat="server" Interval="3000">


XML
<asp:UpdatePanel ID="UpdatePanel9" runat="server">
                                            <Triggers >
                                            <asp:AsyncPostBackTrigger ControlID="Timer1" EventName ="Tick" />
                                            </Triggers>
                                                <ContentTemplate>
                                                    <asp:AdRotator ID="AdRotator1" runat="server" />
                                                </ContentTemplate>
                                            </asp:UpdatePanel>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900