One of our major use of ASP.NET Web Application is to build a Database Driven Application. In the current version of Web Matrix, 2 types of database can be connected and used easily: Microsoft SQL Server and Microsoft Desktop Engine (MSDE).
In the Guided Tour of Web Matrix, we can know that connect, retrieve, display and/or modify data with either of the database above are EXTREMELY easy and convenient.
E.g. If we want to select data and display on screen, we can do a few steps:
Open Web Matrix -> select Data window and tab -> Connect to a Database -> Expand the Table node -> Drag & Drog a Table onto the WebForm -> Drag & Drog the required code from Code Builder...
Yes, connecting to SQL/MSDE is very easy, just a few of simple steps. Well.. I don't want to say too much about this in this article, as it would probably be covered in the Guided Tour of Web Matrix
We found that SQL and MSDE was displayed and connected easily in the WebMatrix interface, but... How can we connect to a MS Access Database? Is it MS Access not support in Web Matrix? This handy tool would perfectly work with a handy database file!
Actually, connecting to MS Access in Web Matrix is definitly possible but require a "bit" of coding, and the key point of connecting to a MS Access Database with SQL / MSDE database is the Namespace. We have to use System.Data.OleDb Namespace if we're going to connect to a MS Access Database. So, the following directive have to declare in a Web Form at first:
<%@ Import Namespace="System.Data.OleDb" %>
Ok, let's take a look at a sample and code about how to connect, retrieve and display data from a MS Access Database to a DataGrid, that's just like and as simple as connecting to a SQL Server / MSDE Database!