I had to work with a program to read/write Microsoft Access Database and I was using .Net Core 2.2 application for processing a large number of files. I later found out that Oledb is no longer supported in the .Net Core world, and then I had to explore additional options. While the Entity Framework option is there, but it would be overkill for the programming needs for the project. I looked into the ODBC based approach and it showed the promise. After some issues and errors, I was able to successfully connect/interact with the access db.
In this article, I am going to discuss the steps to take in order to connect to access db from within a .Net Core 2.2 application written in C# using Visual Studio 2017.
The content of app.config is fairly simple as shown below which stores a key value for datapath:
The following code snippet shows a method named 'ProcessFile(..)' demonstrating demonstrates the use of interaction with Access. The method processes the *.accdb file in the folder path, an input to the method itself. The method looks into the folder path for an access db file. If the file is found, a connection is made and names of the tables (user tables only) are written in the console. In case of error, it writes the error message.
Great tutorials
ReplyDeletewhy does " OdbcConnection" not show up on my version of .net core 3.1?
ReplyDeleteThanks jpal.., I have tested this myself. But there is an active thread in GitHub at https://github.com/dotnet/runtime/issues/32105 could you please check that?
ReplyDelete