Web >> Development >> ASP.Net >> ADO.Net >>  How to read a MySQL database table

create default.aspx with the following <%@ Import Namespace="System.Data.OleDb" %><script runat="server"> ' sub Page_Load dim dbconn,sql,dbcomm,dbread dbconn=New OleDbConnection("Provider=MySQLProv; Data Source='SERVER=localhost;DB=demo;UID=root;PWD=******;PORT=3306'") 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>