1. Create a WebForm
2. Add the following using directive to the top of the page to reference the OleDb versions of ADO.NET objects: using System.Data.OleDb
3. Add the following to the WebForms Page_Load event:
(I use C# but the
VB.NET code is virtually identical)
private void Page_Load(object sender, System.EventArgs e)
{
//Set connection string.
string connectString = "Provider=Microsoft.Jet.OLEDB.4.0;"
+ "Data Source=C:\\Northwind.mdb";
//Pass connection string to OleDbConnection object.
OleDbConnection cn = new OleDbConnection(connectString);
//Open connection.
cn.Open();
//Pass SQL statement to OleDbCOmmand object.
string selectString = "SELECT CategoryID, CategoryName FROM Categories";
OleDbCommand cmd = new OleDbCommand(selectString,cn);
//Execute an OleDbDataReader
OleDbDataReader reader = cmd.ExecuteReader();
//Bind DataReader to DataGrid
DataGrid1.DataSource = reader;
DataGrid1.DataBind();
//Close reader and connection.
reader.Close();
cn.Close();
}
That's the bare bones. Just binds a forward-only, read-only recordset to a DataGrid web control.
HTH,
Bob