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

    


Display items from a database with ASP.net

 

This example will display a series of links from our sample database. The database is available to download below and example can be seen on our ASP.net enabled hosting site.

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

This is a fairly simple example but you should be able to modify this for other databases to suit your own needs.

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:Repeater id="tblsample" runat="server">
<HeaderTemplate>
<table border="1" width="100%">
</HeaderTemplate>

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

<FooterTemplate>
</table>
</FooterTemplate>

</asp:Repeater>

</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
3d text effects(Javascript)
web page downloader(C Sharp)
Random passwords(VB)
DatePart function example(VBScript)
Split a string(PHP)
a calendar(Javascript)
Open display properties background(VB)
Image resizer(PHP)

    




Copyright © 2004 by programmershelp.co.uk