3

I am trying to connect my new Project (ASP.Net Core Framework) with Access Database.

What do I need to enter into: appsettings.json -> "ConnectionStrings"?

And do I have to install something for it?

This framework is new and unfortunately I found no much on the Internet.

I need to connect exactly "Access database".

I would be very happy for detailed information.

2

4 Answers 4

4

Use the "Access Database Engine", which provides an ODBC interface to your application. Be sure to use the 64-bit version (since dotnet core is 64 bit only). Note that it is safe for single-threaded access only. Use the passive parameter at install since the additional Access components are not needed.

AccessDatabaseEngine_X64.exe /passive

Sign up to request clarification or add additional context in comments.

3 Comments

Notice that the connection string format is @"Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=<pathtofile>";
Why is it only safe for single-threaded access? That's not a limitation on the OleDB drivers for Access.
From the link "The Access Database Engine 2010 Redistributable is not intended: ... where the code will run under a system account, or will deal with multiple users identities concurrently, or is highly reentrant and expects stateless behavior."
2

From this link : https://blogs.msdn.microsoft.com/dotnet/2016/11/09/net-core-data-access/

What about OLE DB?

OLE DB has been a great way to access various data sources in a uniform manner, but it was based on COM, which is a Windows-only technology, and as such was not the best fit for a cross-platform technology such as .NET Core. It is also unsupported in SQL Server versions 2014 and later. For those reasons, OLE DB won’t be supported by .NET Core.

1 Comment

It is wrong that OLD DB was dropped. blogs.msdn.microsoft.com/sqlnativeclient/2011/08/29/…
0

You can use the Entity Framework Core which is highly recommended for ASP.net Core applications. Also there are a lot of tutorials out there for using it.

The official documentation lists a suitable Provider for EF Core:

EntityFrameworkCore.Jet -> Microsoft Access files

Please make sure reading the limitations first from the GitHub Page and check if it's still passes your requirements.

Personally i haven't used it yet, but i'm pretty sure that the whole thing can't be too complicated.

2 Comments

This should be the answer. Alas, 4.6.1 dependency.
So that means that this will not work in an asp.net core 2.2 web application right?
-4

Looks here: https://www.connectionstrings.com/

Specifically, here: https://www.connectionstrings.com/access/

Also, try this.

using System;
using System.Windows.Forms;
using System.Data.Odbc; 

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string connetionString = null;
            OdbcConnection cnn ;
            connetionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=yourdatabasename.mdb;";
            cnn = new OdbcConnection(connetionString);
            try
            {
                cnn.Open();
                MessageBox.Show ("Connection Open ! ");
                cnn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can not open connection ! ");
            }
        }
    }
}

Try this as well...

using System;
using System.Windows.Forms;
using System.Data.OleDb; 

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string connetionString = null;
            OleDbConnection cnn ;
            connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=yourdatabasename.mdb;";
            cnn = new OleDbConnection(connetionString);
            try
            {
                cnn.Open();
                MessageBox.Show ("Connection Open ! ");
                cnn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can not open connection ! ");
            }
        }
    }
}

1 Comment

Question is about ASP.Net core specifically, not a "standard" .Net application. Windows forms, and the System.Data.OleDb/System.Data.Odbc namespaces are not available.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.