IIS 7.0, Access 2007 and ASP.NET 2.0

Tags: IIS, Access2007

I don’t get a chance to write webpage code very often, but in my early days of doing samples, it was common to use an Access database.  Access 2007 is the latest version available.  The drivers weren’t installed on my Windows Server 2008 server when I was trying to run an example.  I got the following error.

The ‘Microsoft.ACE.OLEDB.12.0’ provider is not registered on the local machine.

A quick search found the add-on, the link is listed below.  I don’t recommend using Access for medium or higher volume applications, SQL Server or another database is appropriate.  This was a fun exercise and I wanted to share my experience.  Hope this helps.

2007 Office System Driver: Data Connectivity Components

My sample

Download the code

Sample Code
<%@ Page Language=”VB” AutoEventWireup=”false” CodeFile=”authors.aspx.vb” Inherits=”_IISLogscom” %>

<!DOCTYPE html PUBLIC “-//W3C//D
TD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>

<html xmlns=”http://www.w3.org/1999/xhtml“>
<head runat=”server”>
    <title>Untitled Page</title>
    <form id=”form1″ runat=”server”>
        <asp:GridView ID=”GridView1″ runat=”server” AllowPaging=”True”
            AllowSorting=”True” AutoGenerateColumns=”False” DataKeyNames=”ID”
                <asp:CommandField ShowSelectButton=”True” />
                <asp:BoundField DataField=”ID” HeaderText=”ID” InsertVisible=”False”
                    ReadOnly=”True” SortExpression=”ID” />
                <asp:BoundField DataField=”Field1″ HeaderText=”First name”
                    SortExpression=”Field1″ />
                <asp:BoundField DataField=”Field2″ HeaderText=”Last name”
                    SortExpression=”Field2″ />
                <asp:BoundField DataField=”Field3″ HeaderText=”Book Title”
                    SortExpression=”Field3″ />
        <asp:SqlDataSource ID=”SqlDataSource1″ runat=”server”
            ConnectionString=”<%$ ConnectionStrings:ConnectionString %>”
            ProviderName=”<%$ ConnectionStrings:ConnectionString.ProviderName %>”
            SelectCommand=”SELECT [ID], [Field1], [Field2], [Field3] FROM [Authors]”>


Code Behind
Partial Class _IISLogscom
    Inherits System.Web.UI.Page

End Class

Web.config file
<?xml version=”1.0″?>
        <add name=”ConnectionString” connectionString=”Provider=Microsoft.ACE.OLEDB.12.0;Data Source="/App_Data/authors.accdb"” providerName=”System.Data.OleDb” />


Steve Schofield
Microsoft MVP – IIS

Add a Comment