• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

three lines to understand

Hi experts ...
i am new in asp.net .. i run this example in my pc ..it works fine .. i just want to know what is meant by thses three lines :
dbread=dbcomm.ExecuteReader()
customers.DataSource=dbread
customers.DataBind()
/////////////////////////////
this is the whole code
<%@ Import Namespace="System.Data.OleDb" %>
<HTML>
      <script runat="server">
sub Page_Load
dim dbconn,sql,dbcomm,dbread
dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & server.mappath("db/northwind.mdb"))
dbconn.Open()
sql="SELECT * FROM customers"
dbcomm=New OleDbCommand(sql,dbconn)
dbread=dbcomm.ExecuteReader()
customers.DataSource=dbread
customers.DataBind()
dbread.Close()
dbconn.Close()
end sub
      </script>
      <body>
            <form runat="server" ID="Form1">
                  <asp:Repeater id="customers" runat="server">
                        <HeaderTemplate>
                              <table border="1" width="100%">
                                    <tr bgcolor="#b0c4de">
                                          <th>
                                                Companyname</th>
                                          <th>
                                                Contactname</th>
                                          <th>
                                                Address</th>
                                          <th>
                                                City</th>
                                    </tr>
                        </HeaderTemplate>
                        <ItemTemplate>
                              <tr bgcolor="#f0f0f0">
                                    <td><%#Container.DataItem("companyname")%>
                                    </td>
                                    <td><%#Container.DataItem("contactname")%>
                                    </td>
                                    <td><%#Container.DataItem("address")%>
                                    </td>
                                    <td><%#Container.DataItem("city")%>
                                    </td>
                              </tr>
                        </ItemTemplate>
                        <FooterTemplate>
                              </table>
                        </FooterTemplate>
                  </asp:Repeater>
            </form>
      </body>
</HTML>
0
anasalama
Asked:
anasalama
1 Solution
 
imperial_p79Commented:
dbread=dbcomm.ExecuteReader() // This piece of code executes the command against the database and returns your a datareader.
customers.DataSource=dbread // It assigns the 'customers' datagrid's datasource to the datareader that was returned in the previous statement.
customers.DataBind() // This binds the data in the datareader into the datagrid.

Hope this helps!
0
 
anasalamaAuthor Commented:
thank's
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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