Main Menu

HOME

.Net
ASP
Assembly
C
C++
Delphi
HTML
Java
JavaScript
MySQL
PC interface
Powershell
Perl
PHP
VBScript
Visual Basic
XML

Make money selling software. Check this out here

Hosted clickbank mall. Check this out here




   Misc

   Amazon

   Links

    


BInd data to a datalist control

 

This example will display a series of links from our sample database.

In this example we bind the data using a datalist control.

database is available here (Access 2000)

example of it in action is here

 


 

 

<%@ 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">
<HeaderTemplate>
<table border="0" width="100%">
</HeaderTemplate>

<ItemTemplate>
<tr>
<td><%#Container.DataItem("url")%> </td>
</tr>
</ItemTemplate>

<FooterTemplate>
</table>
</FooterTemplate>

</asp:Datalist>

</body>
</html>



 




   Sponsors
 

   Software
500 Java Tips E-book
PHP editor
PERL editor
Beginning Java
Beginning Visual Basic
Learn VB.net
Learn VB 6
VB and databases
ASP image library
C++ builder programming
C++ fundamentals

   Source Code
another word counting example(php)
display service info(VBScript)
populate a select menu from MySQL(PHP)
Image resizer(PHP)
Date last accessed(ASP)
Open/Close CD door example(VB)
Backwards text(Javascript)
Yahoo news(PHP)

    




Copyright © 2004 by programmershelp.co.uk