locked
Microsoft.ACE.OLEDB 12.0 RRS feed

  • Question

  • Hello,

    I am trying to use Visual Studio for the first time in years.  I am trying to re-teach myself what I learned years ago but have never had the opportunity to use.  I have a programming degree.

    I am really having 2 issues.  The main one is with Connecting to an Access Database.  I created a small relational database in Access from Microsoft 365.  The DB was originally stored on OneDrive.  I moved it to my D:\Data folder thinking that may be part of the problem.

    Each time I go to Tools on the VS 2019 menu, wanting to write in VB, I click on  Connect to a Database option, then window Choose Data Source box opens, and I see:  Microsoft Access Database file is selected in the Data Source area.  In the Data Source Provide is .NET Framework Data Provider for OLEDB is selected, (nothing else as an option) I click the Continue button.  The Add Connection box opens and the data source is selected as before, I browse to the file on my D:\Data\PTracker.accdb file is chose.  When I l click the Test Connection or Ok button, the following comes up:  The Microsoft.ACE.OLEDB 12.0 provider is not registered on the local machine message pops up.

    Moving the DB file did nothing.  I read some other questions and tried the ideas, downloaded the file associated with the error, did not work. downloaded the Build 2013 file and it did not work. a few other things I have also tried - no luck.  

    Why am I having this trouble and how can I fix it.  I refuse to think there is no solution. If so, then this issue would render Visual Studio 2019 useless.

    I know this has been a lot to read, but telling you what I experienced and what I have tried as best I could I hope is helpful to find a solution for me.  I appreciate those who take the time to read all this and to help.

    The other issue I have is:  Now that I have started my new project, and have ended up loading it several times over the course of the issues I have had, All I see is the Solution window on the side.  How in the worked do I find the code editor and write some code?  I am completely lost.  

    Thank you for all your time and efforts to help me.  I appreciate it greatly.

    Thank you, 

    Michael.

     

      

    Michael



    • Edited by mcgriffith65 Thursday, June 4, 2020 11:32 PM completely confused
    Thursday, June 4, 2020 10:09 PM

Answers

  • Hello,

    It may be 64 bit vs 32 bit. If the following fails most likely the driver for Office 365 is 64 bit and you need the 32 bit driver would be my guess. What follows below is on a Windows 10 box using Office 2016 so I can verify.

    Simple test, replace the database path and name in the connection string

    Option Strict On
    Option Infer On
    Imports System.Data.OleDb
    
    Public Class AccessTester
        Public Shared Async Function TestConnection() As Task(Of Boolean)
            Dim ConnectionString =
                    "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Database1.accdb"
    
            Using cn As New OleDbConnection With {.ConnectionString = ConnectionString}
                Try
                    Await cn.OpenAsync()
                    Return True
                Catch ex As Exception
                    Console.WriteLine(ex.Message)
                    Return False
                End Try
            End Using
        End Function
    End Class
    

    Call the above in a button click event

    Private Async Sub TestConnectionButton_Click(sender As Object, e As EventArgs) _
        Handles TestConnectionButton.Click
    
        Dim results = Await AccessTester.TestConnection()
        If results Then
            MessageBox.Show("Success")
        Else
            MessageBox.Show("See output window")
        End If
    
    End Sub
    Build settings


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    • Marked as answer by mcgriffith65 Friday, June 12, 2020 3:25 PM
    Friday, June 5, 2020 12:49 AM