菜鸟学堂
在线运行
源代码
<HTML> <HEAD></HEAD> <FONT FACE="Verdana, Arial, Helvetica" SIZE=2> <FONT COLOR=#ff0000><%@ Import Namespace="System.Data.OleDb" %></FONT><br><br><FONT COLOR=#0000ff><script runat="server"><br>sub Page_Load<br>dim dbconn,sql,dbcomm,dbread<br>dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & server.mappath("/db/northwind.mdb"))<br>dbconn.Open()<br>sql="SELECT * FROM customers"<br>dbcomm=New OleDbCommand(sql,dbconn)<br>dbread=dbcomm.ExecuteReader()<br>customers.DataSource=dbread<br>customers.DataBind()<br>dbread.Close()<br>dbconn.Close()<br>end sub<br></script></FONT><br><br><!DOCTYPE html><br><html><br><body><br><br><form runat="server"><br><asp:Repeater id="customers" runat="server"><br><br><HeaderTemplate><br><table border="1" width="100%"><br><tr bgcolor="#b0c4de"><br><th>Companyname</th><br><th>Contactname</th><br><th>Address</th><br><th>City</th><br></tr><br></HeaderTemplate><br><br><ItemTemplate><br><tr bgcolor="#f0f0f0"><br><td><FONT COLOR=#ff0000><%#Container.DataItem("companyname")%></FONT> </td><br><td><FONT COLOR=#ff0000><%#Container.DataItem("contactname")%></FONT> </td><br><td><FONT COLOR=#ff0000><%#Container.DataItem("address")%></FONT> </td><br><td><FONT COLOR=#ff0000><%#Container.DataItem("city")%></FONT> </td><br></tr><br></ItemTemplate><br><br><FooterTemplate><br></table><br></FooterTemplate><br><br></asp:Repeater><br></form><br><br></body><br></html><br> </HTML>
运行结果
在线运行
菜鸟学堂 edu.jb51.net