简体   繁体   中英

How to Connect .NET Core ASP Application to MS Access database

I am trying to create an .net core asp mvc app which will read/write to an MS Access database.

I can't seem to find any information on how this can be achieved, or whether it is in fact possible, apart from this question , but none of the answeres there actually give any useful informtion.

For instance the top answer suggests using Access Database Engine , but there is no mention on how to actually connect to it.

The next answer talks about using Jet , but I got stuck with this issue , and it seems that its not actually supported in dotnet core..

Is it actually the case that I can't access a .mdb file using dotnet core?

If it is possible, could anyone point me towards some sample code or give any guidance as to how this can be done?

You need a custom Connection String that will allow you to access the .mdb file. Use this as your connection string building reference.

You could then instantiate a connection towards the database like this:

using (OleDbConnection connection = new OleDbConnection(ConnectionString)){

     connection.Open();

}

I think the use of OLE DB is deprecated in .net core as per this article.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM