Datasheet

You can double-click on these to open the table, and see and change the data. One thing you might
notice is that you don't see any queries – that's because Web Matrix doesn't support queries in Access.
When connecting to SQL Server, you'll see the stored procedures – you can even create and edit
them – but for Access, you are limited to tables only.
How It Works
There's nothing really to explain about how it works. What we are doing is simply creating a connection
to a database that Web Matrix can use. This isn't required for ASP.NET to fetch data from databases, but
Web Matrix has some great ways to generate code for you, so you don't have to do as much coding.
Creating Data Pages
Pages that display data can be created in a number of ways, and let's first look at the three ways that
Web Matrix uses to save you coding. This is the quickest way to get data into your pages and saves a
great deal of time. However, what it might not do is give you the knowledge to access databases without
using Web Matrix. After we've seen the easy ways, we'll look at the .NET classes that deal with data.
This way you'll have techniques to work with and without Web Matrix.
Displaying Data Using the Data Explorer
You've already seen how easy connecting to a database is using the Data Explorer. Creating pages
directly from this explorer is even easier – all you have to do is drag the table name and drop it onto a
page. This will automatically create a connection on the page and a fully functional data grid. Let's give
this a go.
Try It Out Creating a Grid
1.
Create a new ASP.NET page called Grid1.aspx.
2. From the Data Explorer, drag the Suppliers table onto your empty page as shown in
Figure 8-4:
Figure 8-4
253
Reading from Databases
57084_08.qxp 30/01/2004 8:03 PM Page 253