Question Microsoft ACE.OLEDB.12.0 data provider is not registered on your local machine error

swethajain

Well-known member
Joined
Feb 1, 2010
Messages
48
Programming Experience
Beginner
Hi,
I have an applications in vb.net. In one application everything is working fine and there is no problem with the database. but when i created an application newly, it has an simple insert query. an microsoft ACE.OLEDB.12.0 is not registered on your local machine error is coming. can anyone please help me out why it is happening in only one application. the code is

Module1:
VB.NET:
Module Module1
    Public Const str_DBPath = "M:\3D Project Transfer\68 Lusail Development - Qatar\01 Internal\03 General\Lusail_Test_DB.accdb"
    Public valid As Boolean
    Public Const str_DBPass = "Lusail@HTI_HTV"
End Module
Form1:
VB.NET:
Imports System.Data.OleDb
Public Class Form1
    Dim myConnection As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & str_DBPath & "';Jet OLEDB:Database Password='" & str_DBPass & "'")
    Dim myCommand As OleDbCommand
    Dim result As Integer
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Hide()
       
        cbx_Select.SelectedIndex = 0
        lb_Column2.Hide()
        txtbx_Column2.Hide()
    End Sub
    Private Sub cbx_Select_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbx_Select.SelectedIndexChanged
        Try

            If cbx_Select.SelectedIndex = 1 Then
                lb_Column1.Text = "Trade"
                txtbx_Column1.Text = ""
                lb_Column1.Font = New System.Drawing.Font("Times New Roman", 12, FontStyle.Regular)
                lb_Column2.Show()
                txtbx_Column2.Show()
            Else
                lb_Column1.Text = "Construction Package"
                lb_Column1.Font = New System.Drawing.Font("Times New Roman", 12, FontStyle.Regular)
                txtbx_Column1.Text = ""
                lb_Column2.Hide()
                txtbx_Column2.Text = ""
                txtbx_Column2.Hide()
            End If

        Catch ex As Exception
        End Try
    End Sub

    Private Sub bt_Update_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_Update.Click
        ValidateForm()
    End Sub
    Public Function updation()
        Try
            myConnection.Open()
            MessageBox.Show("Connection Opened Successfully")

        

            If cbx_Select.SelectedIndex = 0 Then

                Dim str_Conpack As String = "insert into [ConstructionPackage](ConPack) values('" & txtbx_Column1.Text & "')"

                Dim cmd As New OleDbCommand(str_Conpack, myConnection)
                Dim ra As Integer = cmd.ExecuteNonQuery
                If ra > 0 Then
                    result = MsgBox("Construction Package Updated", MsgBoxStyle.Information, "Updation")
                End If

            Else

                Dim str_Trade As String = "insert into Trade([Trade],[Tradeinitial]) values('" & txtbx_Column1.Text & " ','" & txtbx_Column2.Text & "')"

                Dim cmd As New OleDbCommand(str_Trade, myConnection)
                Dim ra As Integer = cmd.ExecuteNonQuery
                If ra > 0 Then
                    result = MsgBox("Trade Updated", MsgBoxStyle.Information, "Updation")
                End If

            End If
            myConnection.Close()
            'Catch ex As Exception
            '    MsgBox(ex.ToString)
        Catch myerror As OleDbException
            MessageBox.Show("Error Connecting to Database: " & myerror.Message)
        Finally
            myConnection.Close()
        End Try
    End Function
Private Function Validate_Conpack() As Boolean
        Dim bStatus As Boolean = True
        If txtbx_Column1.Text = "" Then
            txtbx_Column1.Clear()
            txtbx_Column1.Focus()
            'txtbx_Column1.BackColor = Color.Red
            bStatus = False
        Else
            txtbx_Column1.Text = txtbx_Column1.Text
            'txtbx_Column1.BackColor = Color.White
            Return (bStatus)
        End If
    End Function

    Private Sub txtbx_Column1_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtbx_Column1.Validating
        Validate_Conpack()
    End Sub

    Private Sub txtbx_Column2_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtbx_Column2.Validating
        Validate_TradeInitial()
    End Sub
    Private Function Validate_TradeInitial() As Boolean
        Dim bStatus As Boolean = True
        If txtbx_Column2.Text = "" Then
            txtbx_Column2.Clear()
            txtbx_Column2.Focus()
            'txtbx_Column2.BackColor = Color.Red
            bStatus = False
        Else
            txtbx_Column2.Text = txtbx_Column2.Text
            'txtbx_Column2.BackColor = Color.White
            Return (bStatus)
        End If
    End Function
    Private Sub ValidateForm()
        Dim bValidconpack As Boolean = Validate_Conpack()

        Dim bValidtrade As Boolean = Validate_TradeInitial()
        If cbx_Select.SelectedIndex = 0 Then
            If bValidconpack Then
                updation()
            Else
                MessageBox.Show("Values in the fields are missing")
            End If
        ElseIf cbx_Select.SelectedIndex = 1 Then
            If bValidconpack AndAlso bValidtrade Then
                updation()
            Else
                MessageBox.Show("Values in the fields are missing")
            End If
        End If
    End Sub
 
Last edited by a moderator:
So both apps have the same connection string, the first one works whereas the second one gives the ace driver's unregistered error.

My understanding of the Ace 12 driver is either it's installed or it isn't, which means either all apps (that use it) work or they don't. All I can suggest is that you try re-installing the Ace 12 driver again: 2007 Office System Driver: Data Connectivity Components

I've only used Ace12 in one app so far, the rest of my apps that have to use an Access database still use the Jet 4.0 driver which is located in the .Net Framework already.
 
Back
Top