Sample needed

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

Is there a simple asp.net site with MS Access backend that I can use as a
learning example?

Thanks

Regards
 
The quickstart has examples for ado.net - Here is a bit of simple code to
get you started with something at least. Just create a DB in access 2000
(called database.mdb), put it in the same directory as the code and run the
code....cross your fingers and it might even work.

Take a look at the excellent example at w3schools
http://www.w3schools.com/aspnet/aspnet_dbconnection.asp

Have a look through the ADO samples here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
vbwlkwalkthroughdisplayingdataingridinwebformspage.asp

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP



<%@ Page Language="VB"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script language="VB" runat="server">
Sub Page_Load(Src as object, E as EventArgs)

Dim objConnection As OleDbConnection
Dim objCommand As OleDbCommand
Dim objDataReader As OleDbDataReader
Dim strSQLQuery As String


objConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=" & Server.MapPath("database.mdb") & ";")

strSQLQuery = "SELECT * FROM sample "

objCommand = New OleDbCommand(strSQLQuery, objConnection)

objConnection.Open()

objDataReader = objCommand.ExecuteReader(CommandBehavior.CloseConnection)

resultsGrid.DataSource = objDataReader
resultsGrid.DataBind()

End Sub

</script>

<html>
<body>



<asp:DataGrid id="resultsGrid" runat="server"
cellspacing="1"
cellpadding="2"
HeaderStyle-Font-Bold="True"
ToolTip="This is Cool!"
MaintainViewState="false"
/>

</body>
</html>
 
Back
Top