[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 311
  • Last Modified:

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

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)
rptGuestbook.DataBind()
----------------------------------------------------------------------------------
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)
      rptGuestbook.DataBind()
End Sub

</script>
0
ramma
Asked:
ramma
1 Solution
 
stengeljCommented:

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.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now