Adrotator

Discussion in 'ASP .Net' started by Aussie Rules, Jun 4, 2007.

  1. Aussie Rules

    Aussie Rules Guest

    Hi,
    I have a adrotator control on a page, and want to program the connection of
    the control via SQL.

    I have the following code which doesn't seem to do much, and not sure what
    else to do?


    Dim SQLServerConnection As SqlConnection
    Dim SqlConnectionCls As New clsSQL
    SQLServerConnection = SqlConnectionCls.Connect

    Dim SqlCommand As New SqlCommand

    With SqlCommand
    .CommandType = Data.CommandType.StoredProcedure
    .Connection = SQLServerConnection
    .CommandTimeout = 15
    .CommandText = "sproc_GetAddDetails"
    End With

    Me.AdRotator1.DataSource = SqlCommand

    AdRotator1.ImageUrlField = "advert_image"
    AdRotator1.NavigateUrlField = "advert_URLlink"
     
    Aussie Rules, Jun 4, 2007
    #1
    1. Advertising

  2. On Jun 4, 9:31 pm, "Aussie Rules" <> wrote:
    > Hi,
    > I have a adrotator control on a page, and want to program the connection of
    > the control via SQL.
    >
    > I have the following code which doesn't seem to do much, and not sure what
    > else to do?
    >
    > Dim SQLServerConnection As SqlConnection
    > Dim SqlConnectionCls As New clsSQL
    > SQLServerConnection = SqlConnectionCls.Connect
    >
    > Dim SqlCommand As New SqlCommand
    >
    > With SqlCommand
    > .CommandType = Data.CommandType.StoredProcedure
    > .Connection = SQLServerConnection
    > .CommandTimeout = 15
    > .CommandText = "sproc_GetAddDetails"
    > End With
    >
    > Me.AdRotator1.DataSource = SqlCommand
    >
    > AdRotator1.ImageUrlField = "advert_image"
    > AdRotator1.NavigateUrlField = "advert_URLlink"


    I think you forgot to get the data

    AdRotator1.DataSource = SqlCommand.ExecuteReader
     
    Alexey Smirnov, Jun 4, 2007
    #2
    1. Advertising

  3. Hi Aussie,

    As Alexey has suggested, for SqlCommand object, after you initialize it,
    you can call the "ExecuteReader" method (for select ) to return a
    SqlDataReadere object. You can loop all the records in the resultset
    through DataReader

    #Retrieving Data Using a C# .NET DataReader
    http://www.akadia.com/services/dotnet_data_reader.html

    and for ASP.NET complex databound control, you can directly assign the
    DataReader object to their "DataSource" property and call "DataBind" method
    to perform databinding. e.g.

    ==============
    SqlCommand comm;

    ..............


    SqlDataReader reader = comm.ExecuteReader();
    AdRotator1.DataSource = reader;
    AdRotator1.DataBind();
    ===================

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead



    ==================================================

    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.



    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.

    ==================================================



    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Jun 5, 2007
    #3
  4. Aussie Rules

    Aussie Rules Guest

    Hi,

    Thanks for your reply.

    I am still not able to get this to work. My code is as follows. When I view
    source of the HTML page, there are no values for the adrotator at all.
    The Stored Proc works fine.

    I can't see whats wrong......

    Try

    Dim SQLServerConnection As SqlConnection
    Dim SqlConnectionCls As New clsSQL
    SQLServerConnection = SqlConnectionCls.Connect
    Dim SqlCommand As New SqlCommand

    With SqlCommand

    .CommandType = Data.CommandType.StoredProcedure
    .Connection = SQLServerConnection
    .CommandTimeout = 15
    .CommandText = "sproc_GetBannerAdvertDetails"

    End With

    ' I have swapped these arround and tried, but not working. I have put the
    image/navurl after the databind.

    AdRotator1.ImageUrlField = "advert_image"
    AdRotator1.NavigateUrlField = "advert_URLlink"
    AdRotator1.DataSource = SqlCommand.ExecuteReader
    AdRotator1.DataBind()

    Catch ex As Exception


    End Try




    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi Aussie,
    >
    > Regarding on this issue, I have also seen your another one in the
    > following
    > newsgroup:
    >
    > Subject: Adrotator
    > Newsgroups: microsoft.public.dotnet.framework.aspnet
    >
    > Community member Alexey and I have posted some suggestion there. Please
    > have a look and feel free to followup in that thread if you have any
    > further questions.
    >
    > Thanks for your posting!
    >
    > Sincerely,
    >
    > Steven Cheng
    >
    > Microsoft MSDN Online Support Lead
    >
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >

    "Alexey Smirnov" <> wrote in message
    news:...
    > On Jun 4, 9:31 pm, "Aussie Rules" <> wrote:
    >> Hi,
    >> I have a adrotator control on a page, and want to program the connection
    >> of
    >> the control via SQL.
    >>
    >> I have the following code which doesn't seem to do much, and not sure
    >> what
    >> else to do?
    >>
    >> Dim SQLServerConnection As SqlConnection
    >> Dim SqlConnectionCls As New clsSQL
    >> SQLServerConnection = SqlConnectionCls.Connect
    >>
    >> Dim SqlCommand As New SqlCommand
    >>
    >> With SqlCommand
    >> .CommandType = Data.CommandType.StoredProcedure
    >> .Connection = SQLServerConnection
    >> .CommandTimeout = 15
    >> .CommandText = "sproc_GetAddDetails"
    >> End With
    >>
    >> Me.AdRotator1.DataSource = SqlCommand
    >>
    >> AdRotator1.ImageUrlField = "advert_image"
    >> AdRotator1.NavigateUrlField = "advert_URLlink"

    >
    > I think you forgot to get the data
    >
    > AdRotator1.DataSource = SqlCommand.ExecuteReader
    >
     
    Aussie Rules, Jun 5, 2007
    #4
  5. On Jun 5, 7:26 pm, "Aussie Rules" <> wrote:
    > Hi,
    >
    > Thanks for your reply.
    >
    > I am still not able to get this to work. My code is as follows. When I view
    > source of the HTML page, there are no values for the adrotator at all.
    > The Stored Proc works fine.
    >
    > I can't see whats wrong......
    >


    Aussie,

    get rid of the try..catch block, I think you will see what is wrong.

    Hope it helps
     
    Alexey Smirnov, Jun 5, 2007
    #5
  6. Aussie Rules

    Aussie Rules Guest

    Hi,
    Sorry I actually removed the catch code to save space. There was no error
    created(catch never got fired)

    Thanks

    "Alexey Smirnov" <> wrote in message
    news:...
    > On Jun 5, 7:26 pm, "Aussie Rules" <> wrote:
    >> Hi,
    >>
    >> Thanks for your reply.
    >>
    >> I am still not able to get this to work. My code is as follows. When I
    >> view
    >> source of the HTML page, there are no values for the adrotator at all.
    >> The Stored Proc works fine.
    >>
    >> I can't see whats wrong......
    >>

    >
    > Aussie,
    >
    > get rid of the try..catch block, I think you will see what is wrong.
    >
    > Hope it helps
    >
     
    Aussie Rules, Jun 6, 2007
    #6
  7. On Jun 6, 8:40 am, "Aussie Rules" <> wrote:
    > Hi,
    > Sorry I actually removed the catch code to save space. There was no error
    > created(catch never got fired)
    >
    > Thanks
    >
    > "Alexey Smirnov" <> wrote in message
    >
    > news:...
    >
    >
    >
    > > On Jun 5, 7:26 pm, "Aussie Rules" <> wrote:
    > >> Hi,

    >
    > >> Thanks for your reply.

    >
    > >> I am still not able to get this to work. My code is as follows. When I
    > >> view
    > >> source of the HTML page, there are no values for the adrotator at all.
    > >> The Stored Proc works fine.

    >
    > >> I can't see whats wrong......

    >
    > > Aussie,

    >
    > > get rid of the try..catch block, I think you will see what is wrong.

    >
    > > Hope it helps- Hide quoted text -

    >
    > - Show quoted text -


    Well, are you sure that sproc_GetBannerAdvertDetails is working? Try
    to execute it in the Query Analizer (or any other tool to check the db
    output)
     
    Alexey Smirnov, Jun 6, 2007
    #7
  8. Hi Aussie,

    I'm not sure about your backend datasource. I suggest you perform the
    following checK

    1. Direclty bind the DataReader(get from SqlCommand) to a GridView (with
    AutoGenerateColumns="true") to verify whether the reader has returned the
    correctly & expected resultset

    2. For databinding code logic, here is the code in my local test page for
    your reference:


    =================================
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles Me.Load

    BindRotator()

    End Sub

    Private Sub BindRotator()

    Dim conn As SqlConnection
    Dim comm As SqlCommand
    Dim sql As String = "SELECT [id], [name], [description] FROM
    [RVTable]"
    Dim rdr As SqlDataReader


    conn = New
    SqlConnection(WebConfigurationManager.ConnectionStrings("ASPNETTestDBConnect
    ionString").ConnectionString)
    conn.Open()
    comm = New SqlCommand(sql, conn)

    rdr = comm.ExecuteReader()

    AdRotator1.DataSource = rdr
    AdRotator1.ImageUrlField = "name"
    AdRotator1.NavigateUrlField = "description"

    AdRotator1.DataBind()

    rdr.Close()

    conn.Close()


    End Sub
    ================================

    If you have any further finding or question, please feel free to post here.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Jun 6, 2007
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DDK

    Adrotator and flash banner?

    DDK, Jun 25, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    3,352
    akino
    Oct 25, 2007
  2. C Downey

    AdRotator

    C Downey, Jun 16, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    412
    Trevor Benedict R
    Jun 17, 2004
  3. Britney

    how to use adrotator

    Britney, Sep 8, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,995
    Rutger Smit
    Sep 8, 2004
  4. John Buchmann

    Similar to adrotator, but to generate text?

    John Buchmann, Sep 21, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    384
    Hermit Dave
    Sep 25, 2004
  5. Miguel Dias Moura

    AdRotator

    Miguel Dias Moura, Oct 14, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    527
    Jim Cheshire [MSFT]
    Oct 14, 2004
Loading...

Share This Page