Web >> Development >> ASP.Net >> ADO.Net >>  How read a Microsoft Access database table

<%@ Import Namespace="System.Data.OleDb" %><script runat="server"> ' sub Page_Load dim dbconn,sql,dbcomm,dbread dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\wwwroot\webdb\demo.mdb") dbconn.Open() sql="SELECT * FROM addressbook" dbcomm=New OleDbCommand(sql,dbconn) dbread=dbcomm.ExecuteReader() customers.DataSource=dbread customers.DataBind() dbread.Close() dbconn.Close() end sub </script> <body> <form runat="server"> <asp:Repeater id="customers" runat="server"> <HeaderTemplate> <table border="1" width="100%"> <tr> <th align=left>name</th> <th align=left>address</th> <th align=left>tel</th> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td><%#Container.DataItem("name")%></td> <td><%#Container.DataItem("address")%></td> <td><%#Container.DataItem("tel")%></td> </tr> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:Repeater> </form> </body> </html>