Getting MS Access to work with NHibernate

Dec 18, 2008

I am continuing to play with NHibernate and wanted to use MS Access as the database back end. I thought it would be an easy migration that required only a couple NHibernate configuration settings being changed below.

<property name="dialect">
  NHibernate.JetDriver.JetDialect, NHibernate.JetDriver
</property>
<property name="connection.driver_class">
  NHibernate.JetDriver.JetDriver, NHibernate.JetDriver
</property>
<property name="connection.connection_string">
  Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db1.mdb
</property>

But when I started up NHibernate, I received the following error:

System.IO.FileNotFoundException: Could not load file or assembly ‘NHibernate.JetDriver’ or one of its dependencies. The system cannot find the file specified.

File name: ‘NHibernate.JetDriver’

It turns out I needed to add the NHibernate.JetDriver DLL to the project. This DLL is not part of the main NHibernate project. It is located in the NHibernate Contrib project on Source Forge.

Building the NHibernate.JetDriver

  1. Checkout the source code from Source Forge
    1. url: https://nhcontrib.svn.sourceforge.net/svnroot/nhcontrib/trunk
  2. Build the NHibernate.JetDriver project
    1. Directory Location from trunk: /trunk/src/NHibernate.JetDriver
    2. The easiest way to build it is using the NAnt script included in the project (default.build)
      1. the NAnt script creates a “build” folder and places the driver in there
    3. You can also open the project and build it from there
      1. The driver will be located in: NHibernate.JetDriver\bin\Debug

Once you create the NHibernate.JetDriver all you need to do it copy it to your project directory and reference it from your project and then you should be good to use MS Access with NHibernate.

Posted by admin | Categories: NHibernate |

Share with others

2 Responses so far | Have Your Say!

  1. Dave
    March 29th, 2009 at 12:52 pm #

    Thanks for posting this. It really helped me with my project.

    If anyone needs help with creating NHibernate.JetDirect binary I’ll do what I can to help. I learned a few things working on all of this.

    Cheers;

    Dave

  2. Kelly Brown
    June 12th, 2009 at 6:50 pm #

    Hi, very nice post. I have been wonder’n bout this issue,so thanks for posting

Leave a Feedback

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>