rptGuestbook.DataSource = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

Posted on 2005-04-22
Last Modified: 2011-09-20
Hi experts ...
this code is used to select records from Access db table.
i need to understand the meaning of these two lines :
rptGuestbook.DataSource = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
This is the whole code :

<script language="VB" runat="server">
Sub Page_Load (Source As Object, E as EventArgs)
      Dim strConn as string = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("guestbook.mdb") & ";"
      Dim MySQL as string = "SELECT Name, EMail, URL, Comment FROM Guestbook"
      Dim MyConn as New OleDBConnection (strConn)
      Dim Cmd as New OleDBCommand (MySQL, MyConn)
      MyConn.Open ()
      rptGuestbook.DataSource = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
End Sub

Question by:ramma
    1 Comment
    LVL 9

    Accepted Solution


    1st line: rptGuestbook.DataSource = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
    -This line tells the repeater where to get it's data.  

    2nd line: rptGuestbook.DataBind()
    -This line gives (binds) the data to the to the server control (repeater) and all of it's child controls (container.DataItems, et al).

    I think it takes two commands because there are additional things you can do using OnDataBinding and with the viewstate.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video discusses moving either the default database or any database to a new volume.

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now