菜鸟学堂
在线运行
源代码
<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:DataList<br>id="customers"<br>runat="server"<br>cellpadding="2"<br>cellspacing="2"<br>borderstyle="inset"<br>backcolor="#e8e8e8"<br>width="100%"<br>headerstyle-font-name="Verdana"<br>headerstyle-font-size="12pt"<br>headerstyle-horizontalalign="center"<br>headerstyle-font-bold="True"<br>itemstyle-backcolor="#778899"<br>itemstyle-forecolor="#ffffff"<br>footerstyle-font-size="9pt"<br>footerstyle-font-italic="True"><br><br><HeaderTemplate><br>Customers Table<br></HeaderTemplate><br><br><ItemTemplate><br><FONT COLOR=#ff0000><%#Container.DataItem("companyname")%></FONT> in<br><FONT COLOR=#ff0000><%#Container.DataItem("address")%></FONT>, <FONT COLOR=#ff0000><%#Container.DataItem("city")%></FONT><br></ItemTemplate><br><br><FooterTemplate><br>Source: Northwind Database<br></FooterTemplate><br><br></asp:DataList><br></form><br><br></body><br></html><br> </HTML>
运行结果
在线运行
菜鸟学堂 edu.jb51.net