Please note: In an effort to better serve you, we are in the process of restructuring DevCenter. In the process, we have moved many items that you may be used to finding in DevCenter over to the Main Site. If you are having trouble locating something, please try looking at the following places:
With the introduction of DataSource controls in ASP.Net 2.0, a developer can connect the presentation layer directly data taken from an Access database by using an AccessDataSource control. Our controls have complete built in support for this new feature of version 2.0 of the .NET Framework, and thus you can use them to connect to an Access database without having to write a single line of code.
While it is a powerful and easy-to-use object, the AccessDataSource is not without limitations. With respect to the WebGrid, the most important limitation is that the AccessDataSource does not provide hierarchical data. It represents only a single table of data, and there is currently no way to relate multiple AccessDataSource objects to each other.
The steps below demonstrate how to configure a WebGrid to load data from an AccessDataSource. The samples linked to this article illustrate what the end result should look like, and include the Access database file "People.mdb" used in this example.1. Drop a WebGrid, an AccessDataSource control, and a button to a page in a new ASP.NET website.2. Configure the AccessDataSource control. a. Open the DataSource configuration for the AccessDataSource control. b. Click the "Browse" button to select a file. c. Choose the Access database file (extension .mdb) you want to use, and click "OK." Note that the file must exist within the structure of your website. d. On the main wizard, you should see the filename in the text area. Click "Next." e. On this screen, choose the table and columns you want to show in the WebGrid. For this example, we want to select all columns from the "Person" table. Once the columns are selected, click "Advanced" to configure the automated SQL statements. f. Check the "Generate INSERT, UPDATE, and DELETE statements" checkbox, and click "OK." g. Click "Next." h. Click “Test Query” to make sure that the connection works. h. Click "Finish."3. Configure the grid to attach to the datasource control by setting the following properties. a. UltraWebGrid1.DataSourceID = AccessDataSource1 (NOTE: If doing this in code, use AccessDataSource1.UniqueID instead) b. UltraWebGrid1.DisplayLayout.AllowUpdateDefault = Yes (this should be the value set by the default preset) c. UltraWebGrid1.DisplayLayout.AllowAddNewDefault = Yes d. UltraWebGrid1.DataKeyField = "ID" e. UltraWebGrid1.Bands[0].DataKeyField = "ID"Now, when you run the application, you can insert, update, and delete rows within the WebGrid. Clicking on the button will cause a postback; this causes the WebGrid to notify the AccessDataSource of the changes, which will commit all these changes to the database automatically.