3

I'm totally new to Web Programming, and have been asked to produce a web form that will be hosted on the company Intranet Site. The form will be used to submit data to a back end database.

My problem is that the database has been developed using MS Access 2007. Whereas I would like to use ASP.NET MVC 3 I'm not sure I will be able to us MS Access for this as a back-end database. Most examples I seem to find all hook up to SQL Server (Data Context), which i understand is the best way to go about it.

My problem is that due to time restrictions, I wont be able to change this database over to SQL at present. There has been a lot of work done creating things such as Forms, Reports etc within the Access Database that I don't have time to replicate in .Net for now.

Can anyone give me some advice on which would be the best method for building a Intranet Data Entry form in the short term.

I will look to bring the entire project up to date when the time is available.

2
  • 1
    there's no reason why you have to use MSSql as you model. It's just that MS Sql is much better than MS access. What's you preffered data access technology? ADo.Net,Enity framework, something else?
    – Liam
    Jun 25, 2012 at 11:20
  • Thx, I'm familiar with ADO.Net, I'll go with this. Thanks
    – Derek
    Jun 25, 2012 at 11:57

3 Answers 3

2

You should be able to simply add the Access connection string to the web.config file and use that DB instead.

<connectionStrings>
    <add name="MyConn" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|name_of_db.accdb;" providerName="System.Data.OleDb" />
</connectionStrings>

Model-View-Controller is a software design pattern, referring to separation of the interface and logic.

2

You can still use MVC with MS Access. You could use the OLEDBConnection class, however I would recommend you use an ORM such as NHibernate which supports Access connectivity (Tutorial outlined below).

At a later date you can simply map all of the NHibernate mappings to SQL Server and switch the connection string which will point at your new SQL Server database rather than MS Access.

Linking MS Access to NHibernate:

http://www.thoughtproject.com/Snippets/NHibernateWithAccess/

Connecting to MS Access via OLEDB:

http://msdn.microsoft.com/en-us/library/5ybdbtte(v=vs.71).aspx

2
// C#
public void ConnectToAccess()
{
    System.Data.OleDb.OleDbConnection conn = new 
        System.Data.OleDb.OleDbConnection();
    // TODO: Modify the connection string and include any
    // additional required properties for your database.
    conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
        @"Data source= C:\Documents and Settings\username\" +
        @"My Documents\AccessFile.mdb";
    try
    {
        conn.Open();
        // Insert code to process data.
    }
        catch (Exception ex)
    {
        MessageBox.Show("Failed to connect to data source");
    }
    finally
    {
        conn.Close();
    }
}

More info at MSDN.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.