MS Access databases

Categories Web HostingDatabases

MS Access is not designed as a high volume database engine. We don't recommend the use of MS Access databases for heavy traffic sites or if the database is providing dynamic content to the site via SQL queries because it can dramatically slow your site down. The following links may assist with optimisation of your MS access database but we recommend that you migrate your database to MSSQL or MySQL.

To add an MS Access database to your website upload the database onto your hosting account via FTP and then connect your website to the database. You can add more than one MS Access database to your site if required but it is not recommended that you have more than 4 separate databases.

Example connection string

Below is an example of a DSN connection string. You can use this example when modifying your code to connect to your MS Access database:

<%@ Import Namespace="System.Data.OleDb" %>
<script runat="server">
   sub Page_Load
      dim dbconn,sql,dbcomm,dbread
      dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source="& server.mappath("databasename.mdb"))
      dbconn.Open()
      sql="SELECT * FROM valid_entity"
      dbcomm=New OleDbCommand(sql,dbconn)
      dbread=dbcomm.ExecuteReader()
               :
               :
           bind data to web server controls
               :
               :
      dbread.Close()
      dbconn.Close()
   end sub
</script>

MS Access database security

To prevent the database from being downloaded directly via an HTTP connection you will need to specify the code below in your Web.config file:

<system.webServer>
  <handlers>
    <add name="MyForbiddenExtensionHandler" path="*.mdb" verb="*" type="System.Web.HttpForbiddenHandler" preCondition="integratedMode" />
  </handlers>
</system.webServer>

Rate this article