<%@ Import Namespace="System.Data.OleDb" %>
<script runat="server">
sub Page_Load
'variable declarations
dim dbconnection,sqlstring,dbcommand,dbreader
'connect to our database
dbconnection=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & server.mappath("sampledb.mdb"))
'open a connection
dbconnection.Open()
'This is our sql, in this case select all items from the tblsample table
sqlstring="SELECT * FROM tblsample"
dbcommand=New OleDbCommand(sqlstring,dbconnection)
dbreader=dbcommand.ExecuteReader()
tblsample.DataSource=dbreader
tblsample.DataBind()
'close connection and reader objects
dbreader.Close()
dbconnection.Close()
end sub
</script>
<html>
<body>
<asp:Datalist id="tblsample" runat="server"
cellpadding="2"
cellspacing="2"
borderstyle="inset"
backcolor="green"
width="100%"
headerstyle-font-name="Arial"
headerstyle-font-size="10pt"
headerstyle-horizontalalign="left"
headerstyle-font-bold="True"
itemstyle-backcolor="yellow"
itemstyle-forecolor="black"
footerstyle-font-size="9pt"
footerstyle-font-italic="True">
<HeaderTemplate>
URLS
</HeaderTemplate>
<ItemTemplate>
<%#Container.DataItem("url")%>
</ItemTemplate>
<FooterTemplate>
This is our sample database
</FooterTemplate>
</asp:Datalist>
</body>
</html>
|